On Sep 12, 2014, at 8:55 PM, Erik Arvidsson wrote:

> 
> On Sep 12, 2014 6:39 PM, "Jason Orendorff" <[email protected]> wrote:
> >
> > On Thu, Sep 11, 2014 at 4:15 PM, Allen Wirfs-Brock
> > <[email protected]> wrote:
> > > `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.
> >
> > Thanks. The analogy to [[Get]] and [[Set]] helps a lot.
> >
> > (Superficially, possible alternatives to `new^` could include
> > `class()` and `class this`.)
> >
> > One more minor question. Suppose I mistakenly type:
> >
> >     class ColorPoint extends Point {
> >         constructor(x, y, color) {
> >             this = super(x, y); // oops: should be `new super(x, y)`
> >             this.color = color;
> >         }
> >     }
> >
> > Then `new ColorPoint(0, 0, "red")` throws a ReferenceError, because
> > `super(x, y)` implicitly uses `this`. Is that right? Asking just
> > because it seems like it'd be an easy mistake to make.
> 
> It will [[Call]] Point instead of [[Construct]] which may or may not work 
> depending on how Point is defined.
> >
> 

No, Jason was correct.  It would get a Reference Error because `super(x,y)` 
implicitly tries to pass `this` which is still in its TDZ.

Allen 

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to