9 ms·
I know that, the change of "for-range" is good. But it creates more surprises in the uses of "for;;" loops. Please read the cases in that article.
by tapirl 2y ago
I know that, the change of "for-range" is good. But it creates more surprises in the uses of "for;;" loops. Please read the cases in that article.
- foldr 2y agoIt's a change in semantics. So it's surprising if you don't know about the change, and not surprising if you do know about it. I'm familiar with the kind of code that behaves differently under the new scoping rules. Looking at the examples in the post, I don't really share the intuition that the behavior is any more or less surprising for classic 'for' loops as opposed to 'for...range' loops.
- tapirl 2y agoIf you can guarantee that every gophers know the effects of the change. :D The problem of the change is that, if you upgrade your go version in go.mod files, the behavior of the your old code might change. And the change might be not easily found in time. I indeed haven't found any surprising cases caused by the change of "for-range".