Overriding Map/etc with get/set hooks?

Domenic Denicola domenic at domenicdenicola.com
Mon May 20 22:33:41 PDT 2013

On May 21, 2013, at 1:28, "Tab Atkins Jr." <jackalmage at gmail.com> wrote:

> On Mon, May 20, 2013 at 10:20 PM, Domenic Denicola
> Is<domenic at domenicdenicola.com> wrote:
>> Oh, I must have misread your original message. I thought it did not allow storing non-string keys. If it can allow storing any kind of key, like a Map, and it's just the initial data you're referring to, then maybe it is a Map. 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.
> It's a string-keyed map, but that just means that you toString
> everything, as Anne says.  Your contract is still maintained, assuming
> a non-degenerate toString.

Right, I guess it's this contract that gets broken: `x !== y` implies `map.set(x, 1); map.set(y, 2); map.get(x) === 1; map.get(y) === 2`.

More information about the es-discuss mailing list