https://issues.dlang.org/show_bug.cgi?id=21929

--- Comment #5 from Walter Bright <[email protected]> ---
The general rule for determining "what should happen here" when there are
abstractions around pointers (such as arrays, delegates, refs, outs, class
references, etc.), is to rewrite it in explicit terms of those pointers. The
(sometimes baffling) behavior is then exposed for what it actually is, and the
behavior should match.

Granted, there is a special kludge in the compiler to sometimes put the
variables referenced by the delegate into a closure allocated by the gc, but
that doesn't account for variables that go out of scope before the function
scope ends. There is no process to make a closure for them, and adding such a
capability is likely much more complication than added value, and so should
just be an error.

--

Reply via email to