My ECMAScript 7 wishlist

Tab Atkins Jr. jackalmage at gmail.com
Thu Sep 25 11:03:00 PDT 2014


On Wed, Sep 24, 2014 at 3:28 PM, Brendan Eich <brendan at mozilla.org> wrote:
> Tab Atkins Jr. wrote:
>>
>> Using subclassing to bung in some arbitrary trait is really terrible.
>> :/  It requires either adding it up high in your class hierarchy, or
>> having to write a custom NoSuchPropertyClass which extends your
>> superclass, so you can then extend it.
>
> Ok, let's not hand-wave mixin syntax, though (Andrea hacks __proto__). What
> API do you prefer?

I'm partial to magic-named functions, but that's probably my
experience speaking, rather than a more thoughtful opinion.
Symbol-named magic functions would be better, since we have those and
most other languages don't.

Andrea wasn't even hacking __proto__ - they're just adding it to the
class prototype, so newly constructed objects'll have it.

>> I'm rather surprised that the group actually considered that sort of
>> code to be appropriate - it's known that it doesn't compose well with
>> other traits-as-superclasses or normal subclassing.
>
> What code was not appropriate? TC39 balked at standardizing library API, and
> good for them. You want better API, design it!

The use of a Proxy superclass to implement the functionality, which
you demonstrated in an earlier email.

> Or did you want `sealed class` or other such syntax, and I misunderstood?

Nah, using superclasses in general is the bad thing here; it doesn't
compose well without multi-inheritance, which JS likely isn't going to
do.

~TJ


More information about the es-discuss mailing list