Use cases for WeakMap

Mark S. Miller erights at google.com
Sat May 14 16:24:57 PDT 2011


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/82594186/attachment-0001.html>


More information about the es-discuss mailing list