(Weak){Set|Map} subclassing

David Bruant bruant.d at gmail.com
Tue Nov 27 05:07:23 PST 2012


Le 27/11/2012 14:02, David Bruant a écrit :
> Hi,
>
>     var o = {};
>     WeakMap.call(o);
>     WeakSet.call(o);
>     Map.call(o);
>     Set.call(o);
>
> Currently, this works and makes o a weakmap, a weakset, a map and a 
> set...
> I understand collections were spec'ed to enable subclassing, but I 
> don't see the value of being able to subclass this way (I think Jason 
> Orendorff already made the comment somewhere but I can't find it).
> Would it rather make sense that instead of internal [[WeakMapData]], 
> [[MapData]], etc. each would work with a single [[CollectionData]] 
> slot which value can change depending on how it's been defined?
Sorry, very bad working. I meant "can differ" instead of "can change". 
The idea is that [[CollectionData]] is of a certain type decide at 
initialization, but it couldn't change over time for a given object.

> It would still be possible to subclass each (which is the minimum 
> class syntax needs since it's not possible to inherit from several 
> things), but remove the possibility to subclass several of them.
>
> David



More information about the es-discuss mailing list