Suggestion: signal/slot mechanism

Lutger lutger.blijdestijn at gmail.com
Sun Sep 3 10:44:17 PDT 2006


Kristian wrote:
<snip>
> 
> Automatic S/S disconnection at object destructions should also be 
> implemented, usually, which requires the use of a base class.
> 
> I think everybody will agree if I say that the optimal solution would be 
> D supporting S/S mechanism directly.
> 
> It would make using of signals/slots as easy as calling of functions, 
> for instance. But if Walter (and D community) thinks that the S/S 
> mechanism is not important enough to be added to D specs (ever), then 
> Phobos should have a S/S library (in the future). It would make 
> implementation of classes having signals/slots more tedious though. 
> Fortunately using of such classes would be as easy (I looked at some 
> examples of dcouple).

I think there are benefits / downsides to both options of language and 
library implementation. Personally I favor a library option, and if it 
would be included in some (de facto or official) standard library that 
would be good indeed.

In C++ the existing library solutions are very nice and prove that a 
preprocessor like QT uses is not needed at all. I think it can be done 
in D even better, because of delegate support and template features.

The benefit of a library solution is less language bloat, more flexible 
   and possible competition. Some libraries also perhaps don't want to 
use the signal-slot mechanism, like harmonia which prefers to use 
sinking-bubbling.

It's not that it's not important enough, it's more that it fits better 
in a library for a language like D imho.



More information about the Digitalmars-d mailing list