Overriding Map/etc with get/set hooks?

Brendan Eich brendan at mozilla.com
Wed May 22 09:35:15 PDT 2013

On May 22, 2013, at 4:58 PM, "Tab Atkins Jr." <jackalmage at gmail.com> wrote:

> On Wed, May 22, 2013 at 3:40 AM, Brendan Eich <brendan at mozilla.com> wrote:
>> There aren't many Map methods. Write your own workalikes if you need 'em.
>> Done.
> Really?  You're seriously saying that I, and every other spec author,
> every time we need to spec something that's just like a built-in
> collection class but has a type restriction or some other little
> tweak, should just reinvent Map/Set/whatever?

Subclass or wrap, you read that already.

Look, you don't add hooks to Array.prototype for NodeList. Same goes for Map. If subclassing gets you some goodies without losing others, ok.

> I refuse to believe you're actually saying that, because of how bad it
> is for authors.  This is a textbook example of elevating theoretical
> purity over spec authors and web authors.

Rubbish. Put your hooks in your own overrides. Pay for your own lunch.


More information about the es-discuss mailing list