weak references

Jarrett Billingsley kb3ctd2 at yahoo.com
Wed Aug 6 08:53:23 PDT 2008


"dsimcha" <dsimcha at yahoo.com> wrote in message 
news:g7ccbe$2b00$1 at digitalmars.com...
> == Quote from PJP (pete.poulos at gmail.com)'s article
>> Does the D garbage collector provide something similar to the "weak" 
>> references
> in Java?  Weak references don't prevent the object they refer to from 
> being
> garbage collected.  If the object has been garbage collected, the weak 
> reference
> will return null.
>
> Stupid question:  Why would you want weak references other than for 
> circular
> reference elimination with a reference counting GC?

I'd like them to be able to keep track of all instances of a class in 
existence without actually holding true references to them.

That being said, I've never been able to get Bill's weakref.d to work 
properly.  I've filed a Tango bug report but Sean can't reproduce it while I 
can. 




More information about the Digitalmars-d-learn mailing list