What is the status of Weak References?

Brandon Benvie brandon at brandonbenvie.com
Sat Feb 2 21:21:39 PST 2013

Some people would say that garbage collection is the most important
advancement in computer science in the last 20 years....

On Sat, Feb 2, 2013 at 4:16 PM, David Bruant <bruant.d at gmail.com> wrote:

> Le 02/02/2013 20:02, Brendan Eich a écrit :
>  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.
> It is, you don't need to apologize.
>  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<http://wiki.ecmascript.org/doku.php?id=strawman:weak_refs>intro, on the observer and publish-subscribe patterns.
> I guess manual dispose would make a lot of sense. A view knows own its
> lifecycle, it involves adding observers in a bunch of places. When the view
> lifecycle comes to an end for whatever reason, it only makes sense that it
> removes the observers it added. My rule of thumb would be "clean up the
> mess you made".
> Memory leaks are bugs. Like off-by-ones. People should just fix their bugs.
> Garbage collectors encourage the fantasy that people can forget about
> memory. It is a fantasy. A convenient one, but a fantasy nonetheless. A
> fantasy like "we can have a lifestyle that assumes oil is unlimited".
> </naivety>
> <acceptance>
> I guess it's just human nature, so weakrefs are pretty much unavoidable.
> If a weakref to a function is passed to Object.observe, will it auto-get
> the function and unobserve automatically if the .get returns null?
> David
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130203/3cf2d3bf/attachment-0001.html>

More information about the es-discuss mailing list