How would you implement this in D? (signals & slots)

Gerald via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 2 06:49:21 PST 2016


On Monday, 1 February 2016 at 21:44:28 UTC, Enjoys Math wrote:
> On Monday, 1 February 2016 at 21:40:45 UTC, Enjoys Math wrote:
>> module signals_and_slots;
>>
>> import std.algorithm: remove;
>>
>> [...]
>
>
> D's signals & slots:
>
> https://dlang.org/phobos/std_signals.html

I looked at that and perhaps I'm not reading the exampes 
correctly but I'm not sure how useful std.signals is in the real 
world. If you have a bunch of slots which take the same parameter 
types, not unusual in the GUI world, how would that work? The 
other thing that bugs me is lack of naming for slots and signals, 
again in the GUI world where you typically have dozens of these 
on an an individual widget differentiation is quite important.

For my GtkD app where I need my own events between components 
outside of the built-in GTK ones I've just been rolling my own by 
hand using delegates similar to your example. It's pretty trivial 
but admittingly there is a bunch of boilerplate I'd love to 
eliminate via templates if there is a way to address the 
weaknesses with std.signals.


More information about the Digitalmars-d-learn mailing list