On 2/20/23 1:50 PM, Etienne wrote:
On Monday, 20 February 2023 at 02:50:20 UTC, Steven Schveighoffer wrote:
See Adam's bug report: https://issues.dlang.org/show_bug.cgi?id=23627


So, according to this bug report, the implementation is allocating a closure on the GC even though the spec says it shouldn't?

The opposite, the delegate doesn't force a closure, and so when the variable goes out of scope, memory corruption ensues.

I've been writing some betterC and the lazy parameter was prohibited because it allocates on the GC, so I'm wondering what the situation is currently

It shouldn't. Now, lazy can't be `@nogc` (because that's just what the compiler dictates), but it won't actually *use* the GC if you don't allocate in the function call.

I just tested and you can use lazy parameters with betterC.

-Steve

Reply via email to