new instantiation design alternatives

Kevin Smith zenparsing at gmail.com
Mon Sep 15 12:05:41 PDT 2014


>
>
> this would have to be:
>
> constructor(a, b, c) : super(...new^.gimmeSomeSuperArgsYo(a, b, c)) {
>                                               note^,  `new^` rather than
> `this`
>

Right - in my sketch I explained that "this" inside of the create
expression is the same thing as your "new^".  I understand that might be
confusing, though.  Regardless of the token, the idea is the same.

If you want a [[Call]] to the constructor to do an implicit `new`, then you
> need to branch on `new^`:
>
>
Well, what I'm trying to point out is that it's always an error to set
"this" if "new^" is undefined.  So it's kind of strange to force the user
to explicitly write that conditional:

    constructor(x, y) {
        if (new^)
            this = new super(x);
        this.y = y;
    }

With the header approach, it's taken care of:

    constructor(x, y) : super(x) {
        this.y = y;
    }

(using colon just to avoid bikeshedding)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140915/7577c7a3/attachment.html>


More information about the es-discuss mailing list