What is the status of Weak References?

Rafael Weinstein rafaelw at google.com
Fri Mar 1 17:10:59 PST 2013

On Sat, Feb 2, 2013 at 11:02 AM, Brendan Eich <brendan at mozilla.com> wrote:
> 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.

This is exactly right.

I'm preparing an implementation report on Object.observe for the next
meeting, and in it I'll include findings from producing a general
purpose observation library which uses Object.observe as a primitive
and exposes the kind of semantics that databinding patterns are likely
to need.

Without WeakRefs, observation will require a dispose() step in order
to allow garbage collection of observed objects, which is (obviously)
very far from ideal.

> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

More information about the es-discuss mailing list