new instantiation design alternatives

Andreas Rossberg rossberg at google.com
Thu Sep 18 09:51:40 PDT 2014


On 17 September 2014 19:24, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> On 9/17/14, 1:15 PM, Andreas Rossberg wrote:
>>
>> In the light of that, I'm stilling missing the
>> compelling reason to introduce new^ at all.
>
> Say you have:
>
>   class A extends B {
>     constructor() {
>       this = new super();
>     }
>   };
>
>   class B {
>     constructor() {
>        // what here?
>     }
>   };
>
> (apologies for any obvious syntax mistakes).

Well, nothing has to go there. Since B does not have an extends
clause, it has -- according to Allen's gist -- its `this` initialized
implicitly (with an object having the derived constructor's prototype,
like you want).

What new^ adds to the table is the ability to bypass this mechanism
and implement non-standard inheritance or creation patterns within the
class syntax. But honestly, I don't understand why the class syntax
has to directly support such special use cases, let alone _encourage_
them with seductive syntax.

I feel like I'm missing something.

/Andreas


More information about the es-discuss mailing list