Closures and loop scope
Timon Gehr
timon.gehr at gmx.ch
Wed Jun 5 03:49:20 PDT 2013
On 06/05/2013 08:44 AM, Max Klyga wrote:
> On 2013-06-04 19:19:56 +0000, Idan Arye said:
>
>> snip
>
> C# used to behave the same as D behaves now,
You mean the DMD behaviour? No way.
> but in the latest update to C# was changed to properly capture by value.
Again, no way.
Apparently they indeed did a change for C# 5, but all that happened was
that the foreach iteration variable exposed to the user was moved into
the loop body. This is already the case in D, and yet the behaviour is
still the broken one.
http://d.puremagic.com/issues/show_bug.cgi?id=2043.
> Closures should capture (and in most functional languages they do) by value
In which functional languages?
> (at least primitive types) to avoid confusion.
>
Maybe there is a confusion of terminology. What do you mean when you say
capture by value?
More information about the Digitalmars-d
mailing list