Proposal: opt-out local scoping

ihab.awad at ihab.awad at
Thu Aug 28 12:20:50 PDT 2008

On Thu, Aug 28, 2008 at 12:14 PM, Dave Herman <dherman at> wrote:
>> For what value of "global" should the "global" keyword be global? };->
> I interpreted Erik's point to be that the binding of `this' is not lexically
> scoped, so it would be useful to have a lexically scoped variable initially
> bound to the global object. IOW, if I write:
>    global.print("blah blah blah")
> and the same refactoring:
>    (function() {
>         global.print("blah blah blah")
>    })()
> continues to work the same.

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

> But there's no need for a special keyword or anything like that.

Would that really satisfy Erik's use case? He seemed to think that
doing, at the top level --

  var global = this;

  function foo() { = 3;

is vulnerable to some ${person} going --

  function foo() {
    var global = /* something else */ = 3; /* now not the *real* global; system fails! */



Ihab A.B. Awad, Palo Alto, CA

More information about the Es-discuss mailing list