Is there any plans to make working signals in D?

Robert jfanatiker at gmx.at
Sun Apr 14 10:07:58 PDT 2013


> Does it mean you disagree with proposed compiler changes and with the 
> idea we have to create weak reference functionality instead of 
> recreating it every time it is needed (beside of theoretical danger such 
> approach already showed it as a bad thing with `std.stdio.File` as I wrote)?
> 


A weak reference could actually be implemented in the library relatively
easy. ( I basically did it for std.signals2 ) But for std.signals a weak
ref is not really enough, because ideally the slot gets removed if the
target gets destroyed, not only set to null. Updating a collection on
destruction of an object is not that easy as you pointed out (thank you
for that), but I don't see how weak references would help there.

But you just made me think: If it is ok that a signal does not release
the memory for the slot immediately when the object gets destroyed but
only on the next call to emit(), then the implementation would be much
simpler ...

Best regards,
Robert



More information about the Digitalmars-d mailing list