Maps and WeakMaps interoperability

David Bruant bruant.d at gmail.com
Tue Dec 27 07:15:49 PST 2011


Hi,

Maps [1] and WeakMaps [2] are very similar in their API. Since neither
proposal discusses how they should interact with each other, I was
wondering what is supposed to happen when trying to use the API of one
on the other.
-----
var m = new Map();
var key = {};
m.set(key, 37);

WeakMap.prototype.get.call(m, key); // ?
-----

Currently Chrome canary says "illegal access".
Is it the behavior that is wished for the features?
My question obviously extends to Sets and any other such abstraction
that would be considered in the future.

David

[1] http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets
[2] wiki.ecmascript.org/doku.php?id=harmony:weak_maps


More information about the es-discuss mailing list