Is there any plans to make working signals in D?

Denis Shelomovskij verylonglogin.reg at gmail.com
Sun Apr 14 23:22:48 PDT 2013


14.04.2013 21:07, Robert пишет:
>> 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.

Array of weak references is what is needed.

>
> 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 ...

Yes, this is how array of weak references will work because this is how 
weak references work. And this shows one mustn't implement general 
facilities in every case they are needed as he will do mistakes and will 
complicate thinks for himself.

-- 
Денис В. Шеломовский
Denis V. Shelomovskij


More information about the Digitalmars-d mailing list