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

Jason Orendorff jason.orendorff at
Tue May 28 12:21:37 PDT 2013

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

All those methods are generic. Map would be a subclass of Mapping, with its
own fast non-generic methods shadowing the Mapping methods.


- 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list