On Mar 4, 2015, at 1:50 PM, Matthew Robb wrote:
>
> On Wed, Mar 4, 2015 at 2:29 PM, Kevin Smith <[email protected]> wrote:
> In order to allow subclassing as built-ins, we had to opt for the builtin
> model.
>
> Help me make sure I am understanding correctly. This decision does not help
> in making DOM subclassable. It doesn't simply or easily integrate into all
> the existing and somewhat common OOP patterns in user land. What built-ins
> are we talking about then? The decision to fork things here seems MOSTLY
> motivated by a desire to support `class extends Array{}`... Am I crazy? If
> not.... There had to be a better way.
Actually this decision really had nothing to do with subclassing built-ins or
anything else. It just was made as part of the set of changes related to
subclassing. In fact, the updated subclassing design provides an new reliable
way for a function body to distinguish whether it was invoked using [[Call]]
or [[Construct]].
The main reason we disabled [[Call]] invocation of class constructors was
because some TC39 member are interested in possibly providing an enhanced
semantics for [[Call]] invocation of class constructors. Making such calls
illegal in ES6 leaves room for considering such enhancements that would
otherwise have been precluded. One of those possible enhancement that has been
talked about is to implicitly treat a [[Call]] of a class constructor as an
implicit 'new', just like you are suggesting.
>
> On the issue of calling class constructors, I would AT LEAST have preferred
> implicit new on all calls to class constructors. Sure you might get extra
> allocation weight but the way it stands now seems like it could only lead to
> errors in people's assumptions... Assumptions people have built up in their
> experience using the language and that are not only safe TODAY but considered
> best practice.
Not sure what assumptions you are referring to. [[Call]] invocation of
ECMAScript functions have never done an automatic allocation so doing so could
not be conforming to anybodies existing assumptions.
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss