ES6 classes: deferring the creation step

Claude Pache claude.pache at gmail.com
Wed Jul 16 16:19:14 PDT 2014


(Sorry for the delay of response, I am currently in a remote area.)

> Le 6 juil. 2014 à 20:15, André Bargull <andre.bargull at udo.edu> a écrit :
> 
> 
>> 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]

An issue here is that I want to initialise the this-binding of the caller even when the callee ends abruptly (with `throw`).

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

Here is another setting that I've thought of: When `super` is called with a not-yet-initialised this-binding, the this-binding of the callee is in fact a special pointer to the function environment record of the caller, and when the callee wants to read or update it's this-binding, it reads or update the one of the caller. 

—Claude




More information about the es-discuss mailing list