On May 7, 2012, at 4:06 AM, Andreas Rossberg wrote: > On 4 May 2012 06:42, Allen Wirfs-Brock <[email protected]> wrote: > > >> Basic Approach >> Define a global environment model that is flexible enough to both >> maintain compat. with existing browser semantics and allow simpler >> non-browser global semantics >> >> Three sub-environment of the global environment record: >> Built-ins: declarative environment record , immutable bindings for >> standard and impl defined built-in globals >> Global Object: A Object environment record, that shadows the built-ins. >> Content is host defined and may replicate global bindings for globals >> Top Lex: A declarative environment record that shadows the Global >> Object environment for lexical bindings created by top level declarations >> >> These sub-environments are hidden behind the environment record interface of >> a single global environment record, hence their existence does not impact >> the rest of the specification. > > I understand the role of the GO and the TL, but what is the function > of a separate built-ins environment? That is, where and how can it be > observed (in a browser or stand-alone environment)? In the module API?
It permits a host to not provide a GO or to not pollute its GO with ES built-in bindings while still providing a specification of how built-in bindings are resolved relative to explicit global declaration within the program. It is potentially visible by a name (for example WeakArray) being visible via an unqualified reference within a program but not being visible as a property name (for example "WeakArray") on the object that is the top level this value. > > >> When a global environment is initialized it can be configured so var and >> function declaration bindings go into either the Global Object environment >> or the Top Lex environment > > Hm, how does making it "configurable" fit in with the 1JS tale? Even > if the configuration is pre-selected by external means, it still means > that JS-in-the-browser is effectively a different language than > JS-standalone. The declaration static semantic rules are the same whether the var/function bindings are placed in GO or in LT: can't have a both global let-like and var-like declarations for the same name in a Program; a Program can't have a var-like global declaration for a name that had a var-like global declaration in a preceding Program; a Program can't have a var-like global declaration for a name that had a let-like global declaration in a preceding Program. Just like with built-ins, the way this configuration option might be visible would be like inspecting the properties of the GO (if there is one). I don't think this is enough of a difference to say that this host controled configuration choice constitutes a different language. > > In any case, I still think we should strive to make the global scope > as coherent with module scopes as possible. That is, the global scope > itself should be as "module-like" as possible. From that point of > view, it makes perfect sense to keep the global object as a > reification of the toplevel lexical scope (including new binding > forms), analogous to module instance objects reifying module scopes. I think the semantics of the GO is actually quite different from a reified Module object. As a start, my understanding is that a Module object is a sealed object (non-extensible, all properties non-configurable). The GO certainly isn't and (in a browser) arguably can't be. The GO can even be a "host object" with completely non-standard property semantics, so it is hard to make any generalizations about it. This is why I think it is better to try to marginalize the GO rather than giving it the central role in the semantics of the ES6 global declarations. > > I believe that makes for a more consistent (and more compatible) > language than introducing schisms between old vs new built-ins, old vs > new declaration forms, and toplevel vs module scopes. > > Is there any particular reason why you think this is not desirable? > What is e.g. the gain of not reflecting new declarations on the global > object? I think I covered this above and in one of my replies to David. Allen > > /Andreas >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

