ES6 classes: deferring the creation step

André Bargull andre.bargull at udo.edu
Sun Jul 6 13:15:33 PDT 2014


> Moreover, the Completion record (either normal or abrupt) returned
> from [[Call]] will hold an additional [[thisValue]] field,
> which, unless otherwise specified:
>
> * is set to the original `thisArgument` if it was not empty; or,
> * is set to the value (at the time of completion) of the this-binding,
>    if it was initially uninitialised but has been initialised; or,
> * is absent if the this-binding was left uninitialised.

Hmm, mixed feelings about extending the Completion record type to hold 
another field. It could be problematic for implementors to store this 
additional state efficiently. On second thought, it should be possible 
to merge [[thisValue]] with the existing [[Value]] field, and 
conditionally handle [[Value]] == empty in [[Construct]]? [1]


> Moreover, the Completion record (either normal or abrupt) returned
> from [[Call]] will hold an additional [[thisValue]] field,
> which, unless otherwise specified:
>
> * is set to the original `thisArgument` if it was not empty; or,
> * is set to the value (at the time of completion) of the this-binding,
>    if it was initially uninitialised but has been initialised; or,
> * is absent if the this-binding was left uninitialised.

Tail-call semantics may interfere with determining the value of 
"this-binding at the time of completion", because the execution context 
was already popped from the stack at that time. Probably solvable by 
determining the this-binding before performing the tail-call, plus some 
special casing when the tail-call expression is a super-call.


> --------------------------------
>
> When, say, `super.method(..args)` is called, the following steps are taken:
>
> 1. Let `F` be the method referenced by `super.method`.

This part needs to be redefined. `super.method` is an abbreviation for:

1. Let env be GetThisEnvironment().
2. Let baseValue be GetSuperBase(env).
3. Let actualThis be GetThisBinding().
4. Let result be baseValue.[[Get]]("method", actualThis).

But at `this`-binding initialisation time, `actualThis` is still the 
empty placeholder object, so it cannot be used as the receiver argument 
for the [[Get]] internal method call.


[1] https://gist.github.com/anba/e6b525c124d09dafaed6


More information about the es-discuss mailing list