new instantiation design alternatives
allen at wirfs-brock.com
Thu Sep 11 14:15:08 PDT 2014
On Sep 11, 2014, at 1:37 PM, Jason Orendorff wrote:
> It seems like new^ is a new argument that is implicitly passed to all functions.
> What does new^ mean in an arrow function?
> How does new^ interact with a proxy whose target is a constructor?
`new^` has the value of the receiver argument to the [[Construct[[ internal method. This is a parameter newly added to [[Construct]]. Normally it is set to the the value that `new` is applied to. But for `new super` calls it is set to the current `new^` value. In that regard it is like the "receiver" parameter to [[Get]] and [[Set]]. If a constructor is invoked via [[Call]] `new^` has the value `undefined`. that's how you can test for "called as a function" vs. "called as a constructor".
`new^` is lexically scoped, just this `this` and `super`. If an arrow function references `new^` it is the value of the closest lexically enclosing constructor function (a function that implements [[Construct]]).
Just like [[Get]] and [[Set]], the trap for [[Construct]] is extended to include a "receiver" parameter.
> On Thu, Sep 11, 2014 at 3:00 PM, Allen Wirfs-Brock
> <allen at wirfs-brock.com> wrote:
>> oh oops! they are supposed to be "new^". Will fix...
>> On Sep 11, 2014, at 12:55 PM, Boris Zbarsky wrote:
>>> On 9/11/14, 12:35 PM, Allen Wirfs-Brock wrote:
>>>> https://gist.github.com/allenwb/291035fbf910eab8e9a6 summaries the
>>>> main syntactic changes since the meeting and provides rationales them.
>>>> These features are common to both alternates. this is a good place to
>>>> start, after reading the meeting notes.
>>> Allen, thanks for putting this together!
>>> I have a question: what do the uses of "this^" in this document mean? Are those meant to be "new^"?
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>> es-discuss mailing list
>> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss