memory safety and weak references

Brendan Eich brendan at mozilla.com
Mon Apr 1 14:08:25 PDT 2013


Marius Gundersen wrote:
> This is why I suggested, in the other thread, a system for weak event 
> listeners. This would not be a problem if the only allowed argument to 
> a weak reference is a function. An iterable weak set of functions 
> would not have this problem, would solve the suggested usecases for 
> weak references (observables/events):

WeakMaps are useful for membranes too, not just "event listeners":

http://wiki.ecmascript.org/doku.php?id=harmony:proxies&s=proxy#an_identity-preserving_membrane
http://wiki.ecmascript.org/doku.php?id=harmony:proxies&s=proxy#garbage_collection_behavior

/be


More information about the es-discuss mailing list