digitalmars.D.learn - Scope of lambdas and closures
- Rolv Seehuus (17/17) Jul 17 2011 Hi all,
- Daniel Murphy (3/22) Jul 17 2011 That would be http://d.puremagic.com/issues/show_bug.cgi?id=2634
- Rolv Seehuus (9/10) Jul 19 2011 Thanks,
- Daniel Murphy (3/8) Jul 19 2011 That compiles for me.
- Rolv Seehuus (4/13) Jul 30 2011 Ok - Compiler version/os? I'm on MacOS, compiler outputs the following:
- Rolv Seehuus (5/15) Jul 30 2011 Doh, never mind.
Hi all,
First post - I'm learning D, 10yrs exp. with C++.
While trying to generate a static table of functions using lambdas compile time
using mixins, I ran in to
this little (for me) conundrum.
Given that we have this function available:
static void foo(){
writefln("Hohum");
}
This compiles:
void function()[] funcext = [&foo];
Whereas this does not:
void function()[] funcext2 = [function(){foo();}];
Why? What are the technicalities that prevent me from setting up a lambda
during compile-time? It
seems to me that the compiler should be able to figure this out.
Any insights appreciated. :)
Cheers,
-r-
Jul 17 2011
That would be http://d.puremagic.com/issues/show_bug.cgi?id=2634
"Rolv Seehuus" <rolv.seehuus gmail.com> wrote in message
news:ivug6b$o7o$1 digitalmars.com...
Hi all,
First post - I'm learning D, 10yrs exp. with C++.
While trying to generate a static table of functions using lambdas compile
time using mixins, I ran in to
this little (for me) conundrum.
Given that we have this function available:
static void foo(){
writefln("Hohum");
}
This compiles:
void function()[] funcext = [&foo];
Whereas this does not:
void function()[] funcext2 = [function(){foo();}];
Why? What are the technicalities that prevent me from setting up a lambda
during compile-time? It
seems to me that the compiler should be able to figure this out.
Any insights appreciated. :)
Cheers,
-r-
Jul 17 2011
== Quote from Daniel Murphy (yebblies nospamgmail.com)'s articleThat would be http://d.puremagic.com/issues/show_bug.cgi?id=2634Thanks, Is there a related/same reason why this don't compile? unittest { static void stuff(){} static void function()[string] functions = [ "stuff":&stuff ]; } Cheers, -r-
Jul 19 2011
"Rolv Seehuus" <rolv.seehuus gmail.com> wrote in message
news:j04qff$i4s$1 digitalmars.com...
Is there a related/same reason why this don't compile?
unittest {
static void stuff(){}
static void function()[string] functions = [ "stuff":&stuff ];
}
That compiles for me.
Jul 19 2011
== Quote from Daniel Murphy (yebblies nospamgmail.com)'s article"Rolv Seehuus" <rolv.seehuus gmail.com> wrote in message news:j04qff$i4s$1 digitalmars.com...Ok - Compiler version/os? I'm on MacOS, compiler outputs the following: DMD32 D Compiler v2.054 -r-Is there a related/same reason why this don't compile? unittest { static void stuff(){} static void function()[string] functions = [ "stuff":&stuff ]; }That compiles for me.
Jul 30 2011
== Quote from Rolv Seehuus (rolv.seehuus gmail.com)'s article== Quote from Daniel Murphy (yebblies nospamgmail.com)'s articleDoh, never mind. Sorry for wasting your time. Cheers, -r-"Rolv Seehuus" <rolv.seehuus gmail.com> wrote in message news:j04qff$i4s$1 digitalmars.com...Is there a related/same reason why this don't compile? unittest { static void stuff(){} static void function()[string] functions = [ "stuff":&stuff ]; }That compiles for me.
Jul 30 2011








Rolv Seehuus <rolv.seehuus gmail.com>