4 ms·
C# did the same thing in 5.0 https://ericlippert.com/2009/11/16/closing-over-the-loop-variable-considered-harmful-part-two/ https://ericlippert.com/2009/11/16/c
by icholy 3y ago
C# did the same thing in 5.0 https://ericlippert.com/2009/11/16/closing-over-the-loop-variable-considered-harmful-part-two/ https://ericlippert.com/2009/11/16/closing-over-the-loop-var...
- plorkyeran 3y agoWhen C# shipped this change I was working on a large C# codebase and we were very worried about this. After auditing the entire codebase and checking every for loop, we found two pre-existing bugs in code which expected the 5.0 behavior and zero places which relied on the old behavior. Everyone that I've ever talked to who went through the transition has a similar story. In practice no one even incidentally relied on the old behavior. Go rolling it out as an experimental opt-in feature is a good idea, but it'll probably turn out to be unnecessarily cautious and they could have gotten away with just unconditionally enabling it.
- tapirl 3y agoC# only did this on `foreach` loops, not on traditional `for` loops. Go plans to do this on both (`for-range` loops and traditional `for` loops).