Value closures (no GC allocation)

Stanislav Blinov via Digitalmars-d digitalmars-d at puremagic.com
Sun May 21 12:11:46 PDT 2017


On Sunday, 21 May 2017 at 18:17:57 UTC, Adam D. Ruppe wrote:

> But, using the struct stuff, we can add some artificial 
> sweetener now:
>
> return bar(lambda!(x, q{ (int y) => x + y }));
>
> You pass the captures first, then a q{} string literal of the 
> lambda. Here's the implementation of that lambda template:
>
>     template lambda(Args...) {
>// ...
>
>         anon lambda() {
>                 anon a;
>                 // copy the values in
>                 a.tupleof = Args[0 .. $-1];
>                 return a;
>         }
>     }

Looks cool, but it'd still want a GC closure, won't it?


More information about the Digitalmars-d mailing list