DIP60: @nogc attribute

via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 25 04:28:27 PDT 2014


On Thursday, 24 April 2014 at 13:35:39 UTC, bearophile wrote:
>     immutable int x = 3;
>     auto result = data[].map!(y => y * x);
> }
>
>
> test.d(1,6): Error: function D main @nogc function allocates a 
> closure with the GC
>
> Such kind of code is common, so a good amount of range-based 
> code can't be @nogc.

Why can't this be on the stack if the referenced local function 
(lambda) does not outlive the stack frame?


More information about the Digitalmars-d mailing list