> Cool. Would there be a 'global' for each module (for some
> interpretation of "module" but assuming each module has its own
> separate top-level lexical scope, as appears to be the growing
> concensus)?
My intention was for the `use lexical scope' mini-proposal to be
orthogonal to any module proposal. This would be a design question for
modules, not for `use lexical scope'.
I wouldn't treat `global' as anything special, nothing more than part of
the standard library. To that end, one module proposal might start
modules out in a completely empty environment, where you could import
the standard library explicitly (which would include `global'); another
module proposal might start modules out in a default environment that
contains the standard library (which would include `global'). But for
various reasons I'm not ready to start discussing modules with people.
> Would that really satisfy Erik's use case? He seemed to think that
> doing, at the top level --
>
> var global = this;
>
> function foo() {
> global.bar = 3;
> }
>
> is vulnerable to some ${person} going --
>
> function foo() {
> var global = /* something else */
> global.bar = 3; /* now not the *real* global; system fails! */
> }
You can make the same case for any variable. This is just lexical scope
in action. The meaning of a variable reference is its innermost lexical
binding. If you shadow a variable, it's shadowed.
Erik, was this your concern?
Dave
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss