[Issue 2043] Closure outer variables in nested blocks are not allocated/instantiated correctly: should have multiple instances but only have one.

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Oct 2 10:32:16 PDT 2014


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

--- Comment #18 from hsteoh at quickfur.ath.cx ---
If the loop index is mutable, then I think it's OK to make it shared across
loop iterations. Creating a new instance of a loop variable per iteration is
only necessary if (1) the loop index is immutable, and (2) it is being closed
over.

(I also think modifying the loop counter of a foreach loop is a very bad idea
-- you should be using a good ole for(...) loop or while loop instead -- but
that's beside the point.)

--


More information about the Digitalmars-d-bugs mailing list