Closure capture loop variables

via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 30 05:01:30 PDT 2015


On Thursday, 30 April 2015 at 05:23:55 UTC, Vladimir Panteleev 
wrote:
> On Thursday, 30 April 2015 at 03:58:44 UTC, Freddy wrote:
>> On Thursday, 30 April 2015 at 01:19:45 UTC, Vladimir Panteleev 
>> wrote:
>>> Because "copy" is still modified every time "i" is.
>> But shouldn't copy be redeclared every loop iteration (or the 
>> compiler could pretend to redeclare it).
>
> No, it will have the same address every time.

The current behaviour is wrong:
https://issues.dlang.org/show_bug.cgi?id=2043
https://issues.dlang.org/show_bug.cgi?id=8621


More information about the Digitalmars-d mailing list