Signals and Slots in D
Sean Kelly
sean at f4.ca
Fri Sep 29 10:22:52 PDT 2006
Lutger wrote:
> Walter Bright wrote:
>> Lutger wrote:
>>> Almost, it's very simple, like the plain old function pointer as
>>> callback in C. The main difference is:
>>> - when an object which has member functions connected gets detroyed,
>>> there is no problem, no segfaults.
>>
>> Doesn't garbage collection automatically take care of that?
>
> Yes, but you'd have a reference to a dead object in your delegate array
> when it gets deleted and then you emit a signal. You can of course
> remove that reference when you so want to delete an object, then you
> have to track them and miss some ease of use. Or let some language /
> library do it for you.
I believe this was one of the reasons people have requested weak
references for D. Though really, the same thing can be accomplished by
registering a proxy class instead of a reference to the class to be
signaled. I do this all the time in C++.
Sean
More information about the Digitalmars-d
mailing list