4 ms·
Except the ECMAScript changes weren’t changes but additions. Anything using the var keyword gets the traditional semantics, anything using let and const gets le
by chrismorgan 4y ago
Except the ECMAScript changes weren’t changes but additions. Anything using the var keyword gets the traditional semantics, anything using let and const gets lexical scoping.
As an example:
x = [];
for (var i of [1, 2, 3]) {
x.push(() => i);
}
x.map(f => f()) == [3, 3, 3]
x = [];
for (let i of [1, 2, 3]) {
x.push(() => i);
}
x.map(f => f()) == [1, 2, 3]
What’s being proposed for Go is instead a breaking change.
- baq 4y ago> What’s being proposed for Go is instead a breaking change. given the context, it might actually be a fixing change...
- foldr 4y ago>What’s being proposed for Go is instead a breaking change. It sounds like you only get the breaking change in modules that require above a certain version of Go. So this should not break old code. It's perhaps more analogous to the way that "use strict" in JavaScript 'breaks' parsing of octal constants.
- chrismorgan 4y agoAh, my apologies; I missed that part. (I last used Go a decade ago, long before go.mod.) Then this seems fairly reasonable, given also how rarely things will depend on one way or the other.
- masklinn 4y ago> What’s being proposed for Go is instead a breaking change. It’s a breaking change in the same sense that the `”use strict;”` semantics of JS were: it’s not actually a breaking change, because you have to opt in.