ES6 classes: deferring the creation step

Kevin Smith zenparsing at gmail.com
Mon Jul 7 12:02:24 PDT 2014


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

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140707/728ebbe5/attachment.html>


More information about the es-discuss mailing list