Andrea Giammarchi wrote:
I am suggesting that const should:
1. reserve the const name for the whole scope (similar to var)
2. if assigned, keep that value and throw if re-assigned
3. if not assigned, having the very first assignment "seal the deal"
and throw to any other re-assignment attempt
SpiderMonkey's primordial const (from 1999? I forget) was like this,
except (pre-strict-mode) no throw on reassignment attempt, just silent
failure. However it had quirks, e.g.:
// K in scope here, hoisted with value undefined
for (var i = 0; i < N; i++) {
const K = i*i;
...
}
// K still in scope here, like hoisted var
So you could see more than one value for a constant (due to hoisting,
and if the assigning initialiser was in a loop).
TC39 voted "no" long ago. We are not going to do anything like your 1-3
list. Sorry.
Also, I think you are still barking up the wrong tree -- your issue is
not const but a var that you can make non-writable after some fiddling
-- which wants Object.defineProperty.
You are also mixing independent issues such as experimental feature
detection, which is not a burning issue (as Claude said, stop supporting
downrev browsers and browser vendors will stop putting experimental
features in product release channels).
Please stick to one topic per thread if you can. I understand when they
get tangled, but once untangled, don't rehash or go in circles.
/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss