News for hackers. Stuff that matters.
Re:Resolving and Binding by tcard on Tuesday September 12, 2017 @04:28AM (#15225708)
> I can't recall ever seeing code like this in the wild, and if I ever saw it in a code review, I would certainly tell the author to rename the local variable.

This is somewhat common in Go, specially when capturing a for-loop-scoped variable in a closure. It's even recommended in the official FAQ [1].

1. https://golang.org/doc/faq#closures_and_goroutines

Re:Resolving and Binding by munificent on Tuesday September 12, 2017 @12:44PM (#15228863)
:(

That's because Go chose to reuse the loop variable in each iteration instead of binding a fresh one each time.

C# figure out that was a mistake years ago and fixed it in 5.0 [1]. Dart has always bound a new variable in each iteration. I don't know why Go made the choice they did.

[1]: https://blogs.msdn.microsoft.com/ericlippert/2009/11/12/clos...