POV-Ray : Newsgroups : povray.off-topic : Computer language quirks Server Time
30 Jul 2024 00:20:03 EDT (-0400)
  Computer language quirks (Message 11 to 20 of 33)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Darren New
Subject: Re: Computer language quirks
Date: 3 May 2011 16:20:09
Message: <4dc06379@news.povray.org>
On 5/3/2011 12:52, Orchid XP v8 wrote:
> I'm not sure what you're talking about.

Like the IO part of the IO monad.

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

From: Orchid XP v8
Subject: Re: Computer language quirks
Date: 3 May 2011 16:41:12
Message: <4dc06868$1@news.povray.org>
On 03/05/2011 09:20 PM, Darren New wrote:
> On 5/3/2011 12:52, Orchid XP v8 wrote:
>> I'm not sure what you're talking about.
>
> Like the IO part of the IO monad.

The type system doesn't prevent you "seeing" an IO value. You can pick 
them up and move them around just like any other value. It's just that 
you can't do a lot else with them. That's just how the API works; 
nothing to do with the type system.

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: Computer language quirks
Date: 3 May 2011 18:10:10
Message: <4dc07d42@news.povray.org>
On 5/3/2011 13:41, Orchid XP v8 wrote:
> That's just how the API works; nothing to do with the type system.

That's what I'm talking about.

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

From: Lars R 
Subject: Re: Computer language quirks n C++ :-)
Date: 11 May 2011 15:01:13
Message: <4dcadcf9$1@news.povray.org>
In C++ it is supported at lead for function templates:

template<class T>
T foo(int x)
{
   if(x>10) {
      // ... do something interesting
      return foo<T>(x-1);
   } else {
      // ... do something else and finally
      return foo<T>(x*3);
   }
}

int main()
{
    foo<double>(23);
    foo<void>(42);
}



				Lars R.


Post a reply to this message

From: Darren New
Subject: Re: Computer language quirks n C++ :-)
Date: 11 May 2011 15:13:24
Message: <4dcadfd4$1@news.povray.org>
On 5/11/2011 12:01, Lars R. wrote:
> In C++ it is supported at lead for function templates:

Interesting!

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

From: Warp
Subject: Re: Computer language quirks
Date: 11 May 2011 15:57:32
Message: <4dcaea2c@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> I find it mildly distracting that I can't do this:

> void xyz() { ... }

> void abc()
> {
>      if (...)
>         return xyz();
>      else blah blah blah;
> }

  I assumed this to be so in C++ without actually checking. However, now
that I checked it, it seems to work. For example:

//----------------------------------------
#include <iostream>

void bar() { std::cout << "bar()\n"; }

void foo(int i)
{
    if(i < 0) return bar();
    std::cout << "foo()\n";
}

int main()
{
    foo(1);
    foo(-1);
}
//----------------------------------------

compiles and runs just fine.

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: Computer language quirks
Date: 11 May 2011 16:17:27
Message: <4dcaeed7$1@news.povray.org>
On 5/11/2011 12:57, Warp wrote:
> compiles and runs just fine.

Huh. I wonder if that's just a GCC thing or whether that's actually in the 
standard.  I just *actually* tried it with C# and I get "since XYZ returns 
void, the return statement may not be followed by an expression."

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

From: Warp
Subject: Re: Computer language quirks
Date: 11 May 2011 16:27:00
Message: <4dcaf114@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> On 5/11/2011 12:57, Warp wrote:
> > compiles and runs just fine.

> Huh. I wonder if that's just a GCC thing or whether that's actually in the 
> standard.  I just *actually* tried it with C# and I get "since XYZ returns 
> void, the return statement may not be followed by an expression."

  C# isn't C++...

-- 
                                                          - Warp


Post a reply to this message

From: Orchid XP v8
Subject: Re: Computer language quirks
Date: 11 May 2011 16:52:00
Message: <4dcaf6f0$1@news.povray.org>
>> Huh. I wonder if that's just a GCC thing or whether that's actually in the
>> standard.  I just *actually* tried it with C# and I get "since XYZ returns
>> void, the return statement may not be followed by an expression."
>
>    C# isn't C++...

Presumably that's the whole point of C++. ;-)

Oh, wait...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: Computer language quirks
Date: 11 May 2011 19:19:36
Message: <4dcb1988@news.povray.org>
On 5/11/2011 13:27, Warp wrote:
>    C# isn't C++...

I know that. I'm just saying that I was surprised it worked in C++ because 
everything I've ever read except the standard implies it shouldn't. Every 
tutorial etc etc etc says "You can't put a value after a return in a void 
function, and you have to put a value after a return in a non-void 
function."  So it surprised me this was actually not true for C++. So I 
figured I'd try specifically for C#, because maybe all the tutorials for 
*that* were wrong. :-)

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.