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

Le 7 juil. 2014 à 19:02, Kevin Smith <[email protected]> a écrit :

>> 
>> 1.  During phase /* 1 */, the this-binding is uninitialised; trying to access
>>     it through an explicit `this` keyword will throw a ReferenceError.
> 
> This seems overly restrictive to me.   The common case (as in ES5) will be 
> classes that derive from Object, where no such restriction is necessary.
> 

(To be more precise, the intended restriction is a TDZ, just like `const` 
declarations.)

There are trade-offs that should be made. Are there many cases where you want 
to manipulate `this` before calling `super`?

> The crux of the problem is that some host-defined classes that cannot safely 
> separate object allocation from initialization.  What if the @@create hook 
> was allowed to return undefined?  In such a case, your "uninitialized" 
> semantics would apply:  attempting to dereference "this" before calling 
> super(...) would throw an error, and super(...) would essentially set the 
> "this" value?  In all other cases, the currently drafted semantics would 
> apply.
> 

One feature of the proposal is that the first call to `super` invokes the 
constructor with the semantics of [[Construct]] rather than [[Call]], so that 
subclassing classes that have different construct/call behaviour would just 
work. It implies that there is no preliminary creation step. 

—Claude 

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to