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/[email protected]

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/[email protected]

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

Reply via email to