Re:Golang landmines
by catnaroek on Sunday September 18, 2016 @04:36AM
(#12524445)
In C++, you can explicitly specify whether lambdas capture by value or by reference, on a per captured variable basis. Most reasonable programmers would capture `int`s by value. For instance, this program is guaranteed to print all numbers 0..9, not necessarily in order:
Reusing the loop counter variable across iterations in an imperative language is perfectly fine. The confusion comes from capturing a mutable environment by reference, which is a confusing (and hence bad) default.
[ Parent
| on HN ]
There are no comments on this comment yet.