![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Darren New <dne### [at] san rr com> 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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Darren New <dne### [at] san rr com> 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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
>> 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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |