4 ms·
I don’t think it’s so complex. Without i := i, there’s only one i. With i := i, there’s one i per iteration. Closure captures are always by reference. Heap vs
by xiaq 3y ago
I don’t think it’s so complex. Without i := i, there’s only one i. With i := i, there’s one i per iteration.
Closure captures are always by reference.
Heap vs stack allocation don’t affect the language semantics.
- kevincox 3y agoYup. The linked article is a little confused. It thinks that an optimization to pass by value is affecting the behavior. In reality it only passes by value when it is indistinguishable from passing by reference (and it thinks it would be cheaper).