The global object should not be the "global scope instance object"
brendan at mozilla.org
Fri Jan 27 14:49:55 PST 2012
Andreas Rossberg wrote:
> On 27 January 2012 01:57, Brendan Eich<brendan at mozilla.org> wrote:
>> > You're right, the entire outer<script> has been parsed and declarations
>> > processed before anything runs. And the script element is appended to the
>> > DOM too. It all works, except of course you can't tell what's potentially
>> > shadowing anything!
> True, but is that any worse than the situationtoday, where you have
> overwriting instead of shadowing?
I'm not sure "worse" matters so much as "different". Today you can
save/restore, wrap (stack), etc. and JS libraries do this. Adding
nesting for let and const at top level (but keeping overwriting for var
and function) adds to total complexity. But we have to do something with
let and const at top level. The alternative of making let and const
script-local at least avoids the total complexity hit from two models
across scripts: shadowing and overwriting.
OTOH, people may think "oh, finally! const!" and use const declarations
in an early/common script, wanting to see them later on. I still think
we could say "sorry, script-local" and then "use a module".
More information about the es-discuss