Use cases for WeakMap

Erik Corry erik.corry at gmail.com
Mon May 16 00:11:37 PDT 2011


2011/5/15 Brendan Eich <brendan at mozilla.com>:
> Besides attaching metadata, weak maps are important for remembering the
> wrapper or membrane for a given (frozen or not, built-in or "host", not to
> be mutated) object identity. Mark and Andreas knows too well, so I'm
> preaching to es-discuss in the To: line. This is not a use-case for weak
> references.

Is there an extra 'not' in this sentence?  "weak maps are important
[...] this is not a use-case for weak references"

Mark has mentioned membranes as an example of the use of WeakMaps.  I
can see that you don't want the membrane to keep the objects alive,
but is it a problem that the objects keep the membrane alive?  Are we
expecting lots of membranes to come and go and the GC will need to
clean up after them?  I'm not saying it isn't important, I'm just
trying to clarify the use case here.

> Weak maps are useful. I don't think they're misnamed. But we can revisit the
> name if we must.
> /be
>
>
>>
>> >
>> > For example, Firefox extensions want to do this all the time for various
>> > DOM objects (and especially Window).
>> >
>> > -Boris
>> >
>> > _______________________________________________
>> > es-discuss mailing list
>> > es-discuss at mozilla.org
>> > https://mail.mozilla.org/listinfo/es-discuss
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
>
> --
>     Cheers,
>     --MarkM
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


More information about the es-discuss mailing list