es-discuss Digest, Vol 95, Issue 45

Kevin Smith zenparsing at gmail.com
Mon Jan 19 14:18:25 PST 2015


>
>
> They're currently spec'ed to throw.  I wouldn't change that for ES6. It
> could change in the future.
>

Granted.

However, I don't think we should consider the design complete without an
answer to this question, regardless of what gets specced for ES6.  The
answer may carry implications "in the large".

To illustrate my thinking, if we answer that new built-ins should carry on
the "factory when called" tradition of the pre-ES6 built-ins, then we are
setting a very strong precedent for how user classes ought to behave.  In
that case, we can expect that users will want to implement "factory when
called" as a default behavior for their classes.  From that, we can foresee
that the following pattern:

    if (!new.target) return new Whatever(...args);

will become a kind of boilerplate.  Obviously, we want to avoid boilerplate
as a general rule.  When taken together, these considerations might have a
bearing on the overall design.

So I think it will be a good exercise to think a "few steps ahead" on this
question.

(I'm really pleased with this direction in the subclassing design, btw!)

Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150119/2cf6b3ee/attachment-0001.html>


More information about the es-discuss mailing list