Scope of lambdas and closures
Daniel Murphy
yebblies at nospamgmail.com
Sun Jul 17 05:53:23 PDT 2011
That would be http://d.puremagic.com/issues/show_bug.cgi?id=2634
"Rolv Seehuus" <rolv.seehuus at gmail.com> wrote in message
news:ivug6b$o7o$1 at 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-
More information about the Digitalmars-d-learn
mailing list