On Tue, May 28, 2013 at 1:00 PM, Jason Orendorff <[email protected]>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: https://gist.github.com/jorendorff/5662673 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: http://docs.python.org/2/library/collections.html#collections-abstract-base-classes Java has AbstractMap: http://docs.oracle.com/javase/6/docs/api/java/util/AbstractMap.html But I think most languages do not provide anything like this; you just write your own. -j
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

