function is `@nogc` yet allocates closures with the GC work around!

workman workman at gmail.com
Tue Jan 11 11:56:39 UTC 2022


I need a solution to create closures on scope.

The closures will access scope vars, but it's lifetime will be 
end before quit the scope.  So it cloud be create on stack like 
value type.


Is there a workaround to made this work ?

```d
{
   int i = 0;
   int err = doTask(() @nogc nothrow scope {
       i++;
   });
}
```



More information about the Digitalmars-d mailing list