(Weak){Set|Map} subclassing

David Bruant bruant.d at gmail.com
Tue Nov 27 05:02:22 PST 2012


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?

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