Signals and Slots in D

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Sep 29 02:27:40 PDT 2006


Walter Bright wrote:
> The problem in general with hiding pointers is that it'll break with a 
> moving garbage collector. You could work around this by 'pinning' the 
> objects, but pinning objects long term is a bad idea.

That's true of course. It's also through though that the current GC 
*doesn't* move, so it'll work for now. I think as long as a 
WeakReference class (or struct) that works with the current GC is 
provided in the same library as that GC itself it'll be fine.
In the general case, such a class *will* have to be tailored to the GC 
or the other way around.
I believe the latter is what Java does, it has a WeakReference (IIRC) 
class that the GC recognizes. A moving GC could still modify the pointer 
contained in such a class, while not considering it for reachability of 
the pointed-to object (and setting it to null when that object is 
collected).
I think that should also be implementable in Phobos, actually...



More information about the Digitalmars-d mailing list