Value closures (no GC allocation)
Stanislav Blinov via Digitalmars-d
digitalmars-d at puremagic.com
Sun May 21 13:09:14 PDT 2017
On Sunday, 21 May 2017 at 19:43:32 UTC, Adam D. Ruppe wrote:
> On Sunday, 21 May 2017 at 19:11:46 UTC, Stanislav Blinov wrote:
>> Looks cool, but it'd still want a GC closure, won't it?
>
> No, it just generates the same struct you'd write manually.
> That should work fine with @nogc now.
auto create() @nogc {
auto y = 11;
return lambda!(y, q{ (int x) => x+y } )();
}
Error: function create is @nogc yet it allocates closures with
the GC
This:
anon lambda() {
anon a;
// copy the values in
a.tupleof = Args[0 .. $-1];
return a;
}
is a function that is generated by the template. It accesses the
frame of create(). Am I missing something?
How recent of "now" do you mean? I've tested that with
v2.075.0-master-5222639.
More information about the Digitalmars-d
mailing list