Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

Tab Atkins Jr. jackalmage at
Tue May 28 17:15:46 PDT 2013

On Tue, May 28, 2013 at 12:21 PM, Jason Orendorff
<jason.orendorff at> wrote:
> On Tue, May 28, 2013 at 1:00 PM, Jason Orendorff <jason.orendorff at>
> wrote:
>> I still think WebIDL might be the way to go. After all it is WebIDL
>> support that makes your current spec language possible. But I have one more
>> possibly productive suggestion, which I'll try to post today.
> ES6 could provide a Mapping class, in a standard module, that works like
> this:
> All those methods are generic. Map would be a subclass of Mapping, with its
> own fast non-generic methods shadowing the Mapping methods.
> Benefits:
> - User-defined classes that wish to expose a map-like API can subclass Map
> (to inherit Map's implementation) or Mapping (to start fresh). Either way,
> they support all Map methods without having to implement them all.
> - New methods magically appear on all mappings when provided by the
> implementation (or by a polyfill).
> - No new hooks.
> - instanceof would work (within a window).
> - With minor WebIDL support, I think this satisfies Tab's use case of making
> the DOM's map-like objects feel more like Maps with minimal duplication of
> effort.
> Some other languages do this. Python has collections.Mapping:
> Java has AbstractMap:
> But I think most languages do not provide anything like this; you just write
> your own.

This would be *absolutely ideal*.  It would be cool if tc39 defined
this; if not, WebIDL should be able to pick up the slack.  It just
seems useful for authors as well as specs.


More information about the es-discuss mailing list