@nogc closures

vit vit at vit.vit
Sun Aug 5 09:20:21 UTC 2018


It's possible create something like this without errors?

void main()@nogc{   //Error: function `app.main` is `@nogc`
                     //  yet allocates closures with the GC
     import std.experimental.all;

     const int j = 2;
     int i = 0;
     const int[3] tmp = [1, 2, 3];

     tmp[]
         .filter!((x)scope => x == j)    ///main.__lambda1 closes 
over variable j
         .each!((x)scope => i = x);
}


More information about the Digitalmars-d-learn mailing list