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

Tab Atkins Jr. jackalmage at gmail.com
Fri May 31 08:35:02 PDT 2013


On Fri, May 31, 2013 at 8:05 AM, Jason Orendorff
<jason.orendorff at gmail.com> wrote:
> On Tue, May 28, 2013 at 7:15 PM, Tab Atkins Jr. <jackalmage at gmail.com>
> wrote:
>>
>> > 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 [...]
>>
>> This would be *absolutely ideal*.  It would be cool if tc39 defined
>> this; if not, WebIDL should be able to pick up the slack. [...]
>
>
> Is any TC39 member interested in putting this on the agenda for the next
> meeting?
>
> If DOM really wants this, ES (not WebIDL) should provide it.  WebIDL can't
> make Map a subclass of Mapping.

No, but WebIDL *can* put Map on an object's prototype chain, and
redefine all the secondary methods in terms of
iterator/get/set/delete, which are defined by the spec for the
interface.

This isn't absolutely ideal, and I'd appreciate this being done in ES,
but it's a workable solution that I'm pursuing now in
public-script-coord at w3.org.

~TJ


More information about the es-discuss mailing list