Allen Wirfs-Brock (2014-11-26T00:48:40.000Z)
On Nov 25, 2014, at 11:57 AM, Anne van Kesteren wrote:

> On Tue, Nov 25, 2014 at 8:48 PM, Allen Wirfs-Brock
> <allen at wirfs-brock.com> wrote:
>> It would be trivial to change the ES spec. to allow for the script this binding and global object to be set to independent value when a Realm is created.
> 
> Yeah, you said so in 2013 as well, yet nothing happened:
> 
>  https://esdiscuss.org/topic/let-this-object-of-global-environment-be-specified-by-host
>  https://esdiscuss.org/topic/realm-api-and-this-global
>  https://bugs.ecmascript.org/show_bug.cgi?id=1898
> 
> :-(

Given that ES6 doesn't have a public Realm API it really doesn't make much difference.  But if it will make you more comfortable I will make it explicit in the ES6 spec. that a Realm can be created where the this binding and the global object are different values.

> 
> (That said, it's still unclear to me why we need to have three
> constructs to describe one object.)

Architectural layering, separation of concerns, the single responsibility principle ...

They aren't all objects.

A Realm record, is a ES6 specification artifact that represents the complete  the execution context of ES code. It is not an object and does not have object-like semantics. It  is at a lower layer of of the ES specification and using it the complete semantics of ES execution can be defined without depending upon any real metacircularity. As a specification device, an implementation is free to represent it any way it wants. Even as hidden state on an object.  However, the ES spec. intentionally does not associate any of the realm record state with a global object.  To do so would make it a requirement that pass a reference to a global object implies availability (at some level) of the rest of the realm state. 

ES environment records are used to define the semantics of lexical scoping within the ES language. One kind of environment record is a Global environment record that defines the global scope.  Note that a global environment records includes more that just a reference to a global object.  It also includes bindings for global lexical declarations (lets/const/class) which are global but not accessible as properties of the global objects. Environment records are also specification artifacts, it up to an implementation to decide how to represent environment records.  Note that prior to ES5 the ES spec. actually required that objects be used at runtime to represent the scoping environment.  This resulted in various undesirable (but technically required) quirks in the scoping semantics.  ES5 eliminated these problems.

The global object is an actual object.  It has to have ES object semantics, so it is at a higher level of the design than either realm records and  or environment record.

Allen
d at domenic.me (2014-12-04T22:37:27.785Z)
On Nov 25, 2014, at 11:57 AM, Anne van Kesteren wrote:

> Yeah, you said so in 2013 as well, yet nothing happened:

Given that ES6 doesn't have a public Realm API it really doesn't make much difference.  But if it will make you more comfortable I will make it explicit in the ES6 spec. that a Realm can be created where the this binding and the global object are different values.


> (That said, it's still unclear to me why we need to have three
> constructs to describe one object.)

Architectural layering, separation of concerns, the single responsibility principle ...

They aren't all objects.

A Realm record, is a ES6 specification artifact that represents the complete  the execution context of ES code. It is not an object and does not have object-like semantics. It  is at a lower layer of of the ES specification and using it the complete semantics of ES execution can be defined without depending upon any real metacircularity. As a specification device, an implementation is free to represent it any way it wants. Even as hidden state on an object.  However, the ES spec. intentionally does not associate any of the realm record state with a global object.  To do so would make it a requirement that pass a reference to a global object implies availability (at some level) of the rest of the realm state. 

ES environment records are used to define the semantics of lexical scoping within the ES language. One kind of environment record is a Global environment record that defines the global scope.  Note that a global environment records includes more that just a reference to a global object.  It also includes bindings for global lexical declarations (lets/const/class) which are global but not accessible as properties of the global objects. Environment records are also specification artifacts, it up to an implementation to decide how to represent environment records.  Note that prior to ES5 the ES spec. actually required that objects be used at runtime to represent the scoping environment.  This resulted in various undesirable (but technically required) quirks in the scoping semantics.  ES5 eliminated these problems.

The global object is an actual object.  It has to have ES object semantics, so it is at a higher level of the design than either realm records and  or environment record.