std.signals2 proposal
Kagamin
spam at here.lot
Wed Nov 7 05:59:52 PST 2012
On Tuesday, 6 November 2012 at 15:31:42 UTC, eskimo wrote:
>
>> I've not read the code and I'm not 100% sure of the intentions
>> of std.signal but why not just call the delegate as is?
>>
>
> Signals are a way of a very loose coupling of components. This
> loose
> coupling is the reason why people usually expect weak reference
> semantics from signals. So people expect a signal connection to
> simply
> vanish when the observer object dies, instead of keeping it
> alive
> because it holds a reference to it.
As long as you keep strong reference to the observer, it won't
die.
Having signals with weak reference semantics can be surprising
for a garbage collected language: AFAIK Java and C# use strong
reference semantics for observers. On the other hand one may want
strong reference semantics: if you have e.g. a button.click
listener, you don't want it to die prematurely, do you?
More information about the Digitalmars-d
mailing list