Challenge

rsw0x via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 30 07:43:59 PDT 2015


On Sunday, 30 August 2015 at 13:36:45 UTC, anonymous wrote:
> On Sunday 30 August 2015 12:21, rsw0x wrote:
>
>> [...]
>
> I think this shouldn't compile and it only does so because of 
> issue 14771.
>
> https://issues.dlang.org/show_bug.cgi?id=14771
>
> The delegate in foo uses a local variable and it's returned 
> from the function, so it needs a closure. Where does the 
> closure go if not on the GC heap?
>
> See also this Learn thread about how to call map with a 
> delegate in a @nogc function:
>
> http://forum.dlang.org/post/kpwbtskhnkkiwkdsfzby@forum.dlang.org
>
> Ali Çehreli's solution there may or may not actually be @nogc, 
> but I'm afraid it relies on issue 14771 any way:
>
> http://forum.dlang.org/post/mqr506$10kf$1@digitalmars.com

Is there any reason that closure in this particular example can't 
be created on the stack? Seems a bit weird.


More information about the Digitalmars-d mailing list