The global object as the "global scope instance object"

Andreas Rossberg rossberg at google.com
Tue Jan 24 10:32:09 PST 2012


On 24 January 2012 18:49, Brendan Eich <brendan at mozilla.org> wrote:
> Andreas Rossberg <mailto:rossberg at google.com>
>> Consequently, I maintain my claim that it is impossible to reconcile
>> sane let/const semantics with the idea of having toplevel bindings
>> represented as data properties on the global object.
>
> I agree. For ES4 we equated let to var at top-level, a mistake. For ES6 IIRC
> you have proposed an implicit block scope at top level (of functions at
> least, I don't see why not programs as well), whereby let and const bind
> lexically. Only var and function make global object properties.

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.

(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.

Var would keep its current semantics, aliasing a data property. For
functions, it doesn't matter much either way, but for consistency with
other static bindings I'd move to accessor-based semantics in ES6.

/Andreas


More information about the es-discuss mailing list