Goals:
Duplicate current browser global semantics
Existing ES5 built-ins are properties of "the global object"
Global Function and Var declarations create properties of "the global
object"
Ad hoc semantics relating explicit Function/Var global bindings and
non-declared global object properties include attribute and inheritance issues
Don't make the web compatible global object worse
New declaration forms (let/const/class) shouldn't pollute "the global
object"
Don't add any new ES built-in bindings to "the global object"
Don't force non-browser or nested global environments hosts to duplicate
quirky browser global semantics
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 for bindings created by top
level declarations
These sub-environments are hidden behind the environment record interface of
the single global environment record, hence there existence does not impact the
rest of the specification.
When a global environment is initialized it can be configured so var and
function declaration bindings go into either the global object or Top Lex
The structuring of Top Lex to supple multiple program fragments is an
orthogonal issue. However, I favor a single top lex shared by all
program/script fragments.
Common ways to configure the global environment:
Browser compat:
ES5 built-in global bindings replicated on the global object
any new ES6 built-in global bindings not replicated on the global object
global var/function declarations create bindings on global object
global const/let/class/module declarations create bindings in Top Lex
This would be specified in the browser optional/normative annex.
Clean Global Object
No built-ins replicated on global object
all ES top level declarations (including var/function) create binding
in Top Lex
global object properties can only be created via explicit reference to
global this
No Global Object
Global object is undefined
all ES top level declarations (including var/function) create binding
in Top Lex
Thoughts? I'm ready to write the spec for this.
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss