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.

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

Reply via email to