Use cases for WeakMap

Oliver Hunt oliver at apple.com
Sat May 14 17:03:07 PDT 2011


I suspect i did suggest WeakMap but I think I misunderstood the proposal.  I felt the goal was to prevent the key from being kept around forever even when the value was gone, I did not expect the key to keep the value alive.

--Oliver

On May 14, 2011, at 4:24 PM, Mark S. Miller wrote:

> 
> 
> On Sat, May 14, 2011 at 4:21 PM, Oliver Hunt <oliver at apple.com> wrote:
> 
> On May 14, 2011, at 4:03 PM, David Bruant wrote:
> 
> > Le 15/05/2011 01:01, Oliver Hunt a écrit :
> >> No, I am wrong, if i have a key that i can ever reuse, the map is strong, because the key will keep the value live.  These aren't weak maps, they are strong maps that don't leak keys that have become dead.
> >>
> >> I can kind of see the value of this kind of structure, but I don't believe it is a WeakMap.
> > What is your definition of a WeakMap?
> > How is the current strawman different from this definition?
> 
> In the definition of a weak map that I have always known, the key does not keep the mapped value alive.  In the weakmaps proposal the key keeps the mapped value alive.
> 
> Like <http://wiki.ecmascript.org/doku.php?id=strawman:weak_references#a_weakvaluetable>?
> 
> Is there some prior system that refers to these as WeakMaps?
> 
>  
> 
> So if you can ever lookup a key again, the value cannot be collected, so your "cache" will hold onto every entry forever.
> 
> > David
> --Oliver
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 
> 
> 
> -- 
>     Cheers,
>     --MarkM

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110514/1da8034d/attachment.html>


More information about the es-discuss mailing list