The global object as the "global scope instance object"

Brendan Eich brendan at mozilla.org
Tue Jan 24 11:24:04 PST 2012


> Andreas Rossberg <mailto:rossberg at google.com>
> January 24, 2012 10:32 AM
>
> Taken literally, an implicit block scope at toplevel would imply that
> let/const-bound properties won't show up on the global object at all.
> That seems to devalue the global object and/or let.

I prefer to think of it as saving 'let' from the degradations of the 
global object ;-).

I am skeptical we will banish var, ever. Consider the object detection 
pattern:

   if (!this.foo) {
     var foo = function () {
       ...
     };
   }

No way to make this work with let.
>
> (Part of) what I proposed in the OP of this thread is that for the
> toplevel, we can still safely reflect let/const bindings on the global
> object, but through accessor properties -- just like with module
> instance objects. Solves all the problems we just discussed, while
> also keeping let useful as the new var.

I saw, clever approach -- haven't had time to evaluate it for 
compatibility. Seems optimizable.

/be



More information about the es-discuss mailing list