What is the status of Weak References?
brendan at mozilla.com
Sat Feb 2 11:02:45 PST 2013
David Bruant wrote:
> Interestingly, revocable proxies require their creator to think to the
> lifecycle of the object to the point where they know when the object
> shouldn't be used anymore by whoever they shared the proxy with. I
> feel this is the exact same reflections that is needed to understand
> when an object isn't needed anymore within a trust boundary...
> seriously questioning the need for weak references.
Sorry, but this is naive. Real systems such as COM, XPCOM, Java, and C#
support weak references for good reasons. One cannot do "data binding"
transparently without either making a leak or requiring manual dispose
(or polling hacks), precisely because the lifecycle of the model and
view data are not known to one another, and should not be coupled.
See http://wiki.ecmascript.org/doku.php?id=strawman:weak_refs intro, on
the observer and publish-subscribe patterns.
More information about the es-discuss