Mike L. Wrote:

> The following code compiles fine for me with dmd 1.043:
[snip]
> Should this be a compiler error?

No, because what you are asking for requires full escape analysis (that is, 
determining if a variable escapes its scope).  In order to do that, dmd needs 
full sources or an intermediate format for compilation, and not to mention a 
major redesign of the compiler.  These sorts of things have been asked for in 
the past, to no avail.  Either the solutions require major annotation by a 
person, or major redesign of the language.

D2 handles this by allocating a closure.  D1 is in feature freeze so it won't 
get any enhancements.  Both solutions (silently allocate heap data "just in 
case", or just close your eyes and still compile) kinda suck.  The best I can 
say is, you should learn to avoid these types of things.

-Steve

Reply via email to