Thread overview
WeakRef
Jan 21, 2008
Bill Baxter
Jan 21, 2008
Bill Baxter
Jan 26, 2008
Bill Baxter
January 21, 2008
Is this a good way to make a weak reference to an object? Am I missing anything?  The little unittest seems to work.

It would be nice if something like this were in the standard library so I wouldn't have to worry about using the undocumented notifyRegister and notifyUnRegister methods.

--bb




January 21, 2008
Bill Baxter wrote:
> Is this a good way to make a weak reference to an object?
> Am I missing anything?  The little unittest seems to work.
> 
> It would be nice if something like this were in the standard library so I wouldn't have to worry about using the undocumented notifyRegister and notifyUnRegister methods.
> 
> --bb

Oh, and that's public domain if anyone wants to use it.

--bb
January 26, 2008
Bill Baxter wrote:
> Is this a good way to make a weak reference to an object?
> Am I missing anything?  The little unittest seems to work.
> 
> It would be nice if something like this were in the standard library so I wouldn't have to worry about using the undocumented notifyRegister and notifyUnRegister methods.
> 
> --bb

Looks like just a week before I sent this Tango got weak pointers.  So now you can do a similar thing in Tango too.
    http://www.dsource.org/projects/tango/forums/topic/341

BTW tango's names for the subscribe/unsubscribe functions are slightly better-named than Phobos'!
    rt_attachDisposeEvent and rt_detachDisposeEvent
 vs
    notifyRegister and notifyUnRegister

They're not documented in Phobos, so it's not too late to pick some better names (or provide some better aliases anyway)!

--bb