Overriding Map/etc with get/set hooks?

Domenic Denicola domenic at domenicdenicola.com
Mon May 20 22:27:40 PDT 2013


On May 21, 2013, at 1:23, "Anne van Kesteren" <annevk at annevk.nl<mailto:annevk at annevk.nl>> wrote:

On Tue, May 21, 2013 at 6:20 AM, Domenic Denicola
<domenic at domenicdenicola.com<mailto:domenic at domenicdenicola.com>> wrote:
As long as the contract that `map.set(x, y); map.get(x) === y` works for any `x` and `y`, then you're probably fine.

I think it would have to subclass those methods by using toString() on
the argument passed. It seems that would still be Map-like though.


Hmm, so that invariant wouldn't hold? I assume `has` would be similarly broken? Seems… not so  Map like, besides perhaps having some operations with the same name as Map's.

Relevant: http://en.wikipedia.org/wiki/Liskov_substitution_principle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130521/cafb5b08/attachment-0001.html>


More information about the es-discuss mailing list