D2 weak references

Jason House jason.james.house at gmail.com
Wed Apr 15 11:29:16 PDT 2009


Stewart Gordon Wrote:

> Jason House wrote:
> > Does anyone have a weak reference library for D2?
> > 
> > Without that, hash tables and search trees don't mix. I'm hoping that 
> > a weak reference library can be merged into druntime.
> 
> Weak references don't fit well into D at the moment.  It's been talked 
> about before (albeit not in reference to D2 in particular):
> 
> http://www.digitalmars.com/d/archives/digitalmars/D/713.html
> http://www.digitalmars.com/d/archives/digitalmars/D/Weak_references._69761.html
> 
> and probably others.

I participated in the more recent of those threads.

I feel like I have a great application for weak pointers. The best manual memmory management of search trees and hashtables is to do mark and sweep. That should sound awfully familiar...

 
> But I think that, if D gained weak references as a built-in feature it 
> would work well and be useful.  A decent library implementation may 
> otherwise be possible if D's GC API gains:
> - an explicit pinning mechanism
> - a means of creating listeners on the GC
> 
> Stewart.

Everything is pinned at the moment and Tango's GC (and therefore druntime's GC) has an explicit notification mechanism. The big advantage to having a weak ref implementation in the runtime is that it'll evolve with the GC as well as pool people's bug fixes / ports.



More information about the Digitalmars-d mailing list