On May 11, 2011, at 12:54 PM, Brendan Eich wrote:

> On May 11, 2011, at 12:44 PM, Oliver Hunt wrote:
> 
>> So you want to do
>> if (map.has(bar))
>>  wiffle = map.get(bar)
>> 
>> or some such?
>> 
>> The problem here is that you can't guarantee that GC won't happen between 
>> those two calls, and therefore you could still end up getting undefined in 
>> response to the get.
> 
> Not if bar refers to the key object, since it must be a strong ref.

Re-reading the weakmap definition makes weakmaps seem fundamentally different 
to any other weakmap API i've ever encountered.  The most common weakmap use 
cases i am aware of are all essentially caches, and this definition doesn't 
support that use case at all.

It seems completely bizarre to me that the key should act as a root for the 
value it is associated with.

--Oliver


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to