@@new

Jason Orendorff jason.orendorff at gmail.com
Tue Jun 17 13:34:22 PDT 2014


On Tue, Jun 17, 2014 at 2:55 PM, Erik Arvidsson
<erik.arvidsson at gmail.com> wrote:
> What would `C.prototype.constructor` look like with your proposal?

ES6 already achieves `C.prototype.constructor === C`, for both
functions and classes, simply by defining the two properties that way
(in [1] steps 6 and 7). I wouldn't change that.

> Is `C === C[@@new]`?

Good question. I think calling `C(...args)` should be the same as
calling `new C(...args)`. How best to specify that, I'm not sure.

I don't think `C === C[@@new]` needs to be a goal, since it wouldn't
hold for regular functions, or for classes that don't define a
constructor (those inherit their @@new method from the base class), or
for classes that contain a `static [Symbol.new]()` method. But as an
implementation detail, if that's the easiest way to specify it, OK.

-j

[1]: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-makeconstructor


More information about the es-discuss mailing list