www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Signals and slots?

reply Georg Wrede <Georg_member pathlink.com> writes:
Hi!

How hard would it be to have signals&slots included in the D spec?

An intro at http://doc.trolltech.com/3.3/signalsandslots.html describes 
the idea as far as Qt is concerned, but this might be a generally useful 
thing in any OO language?

Since they have implemented this with a couple of preprocessor definitions,
it probably wouldn't be too hard to incorporate in the D language core?

Code shops usually have their staff writing stock classes between assignments,
and having signals&slots would make these classes handier to use. And large
programming projects would benefit from looser coupling between objects.

I'm not saying SS should be used _instead_ of regular object methods, just
that they add value and versatility to a class. And adding some SS to 
already existing classes could make them usable in new contexts.

(I know, I know) this might be a little too late for D 1.0. :-(

Then again, having SS in D 1.0 could make writing usable libraries easier.
By D 2.0 we'd have a real mean package!

Writing games, UI, multithreaded, real-time, control, OS, ... you name it,
SS would be of help.
Dec 02 2004
next sibling parent "Zz" <Zz Zz.com> writes:
Look at http://libsigc.sourceforge.net/ which implements it in c++ without
all that pre-processor stuff.
There is also one in Boost.

Zz



"Georg Wrede" <Georg_member pathlink.com> wrote in message
news:conii3$tkv$1 digitaldaemon.com...
 Hi!

 How hard would it be to have signals&slots included in the D spec?

 An intro at http://doc.trolltech.com/3.3/signalsandslots.html describes
 the idea as far as Qt is concerned, but this might be a generally useful
 thing in any OO language?

 Since they have implemented this with a couple of preprocessor
definitions,
 it probably wouldn't be too hard to incorporate in the D language core?

 Code shops usually have their staff writing stock classes between
assignments,
 and having signals&slots would make these classes handier to use. And
large
 programming projects would benefit from looser coupling between objects.

 I'm not saying SS should be used _instead_ of regular object methods, just
 that they add value and versatility to a class. And adding some SS to
 already existing classes could make them usable in new contexts.

 (I know, I know) this might be a little too late for D 1.0. :-(

 Then again, having SS in D 1.0 could make writing usable libraries easier.
 By D 2.0 we'd have a real mean package!

 Writing games, UI, multithreaded, real-time, control, OS, ... you name it,
 SS would be of help.
Dec 02 2004
prev sibling next sibling parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
People have suggested exactly this before.  I am going to re-read that 
page on Qt Signals (partly just because they sound interesting), but I 
think the general conclusion was that signals could be pretty well 
handled with delegates.

The one big problem (as I remember it) is garbage collection of objects 
which are the target of signals.  You can't gc an object until all 
references to it (including references which are part of delegates) are 
gone.  Likewise, if you manually delete something, you need a way to 
inform whoever holds the delegate to not call it (since the object is no 
longer valid).

People have argued that this is a place where weak references would be 
very useful.

I (may) post more comments later after I've reread the article in detail.
Dec 02 2004
parent reply Georg Wrede <Georg_member pathlink.com> writes:
In article <connr8$172e$1 digitaldaemon.com>, Russ Lewis says...
People have suggested exactly this before.  I am going to re-read that 
page on Qt Signals (partly just because they sound interesting), but I 
think the general conclusion was that signals could be pretty well 
handled with delegates.
I can't imagine teaching delegates in the first semester. But SS I could!
The one big problem (as I remember it) is garbage collection of objects 
which are the target of signals.
Heh, I just saw the light. What if the target object _sends a signal_ at its demise? The compiler could implicitly insert this in the destructor of SS-aware objects. From an object's point of view, all SS is about is throwing signals up in the air. If someone is interested, then fine. You neither care or even know. So yelling "I die" can be heard by the SS system itself (and whoever else might be interested).
Dec 03 2004
next sibling parent reply Georg Wrede <Georg_member pathlink.com> writes:
In article <copc32$h4q$1 digitaldaemon.com>, Georg Wrede says...
In article <connr8$172e$1 digitaldaemon.com>, Russ Lewis says...
People have suggested exactly this before.  I am going to re-read that 
page on Qt Signals (partly just because they sound interesting), but I 
think the general conclusion was that signals could be pretty well 
handled with delegates.
I can't imagine teaching delegates in the first semester. But SS I could!
The one big problem (as I remember it) is garbage collection of objects 
which are the target of signals.
Heh, I just saw the light. What if the target object _sends a signal_ at its demise? The compiler could implicitly insert this in the destructor of SS-aware objects. From an object's point of view, all SS is about is throwing signals up in the air. If someone is interested, then fine. You neither care or even know. So yelling "I die" can be heard by the SS system itself (and whoever else might be interested).
Oh, and to top this off: have the SS target references not counted by the GC. This way, when an object becomes otherwise unreferenced, the GC collects the object, and its destructor informs the SS.
Dec 03 2004
parent Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Georg Wrede wrote:
 In article <copc32$h4q$1 digitaldaemon.com>, Georg Wrede says...
 Oh, and to top this off: have the SS target references not counted
 by the GC. This way, when an object becomes otherwise unreferenced,
 the GC collects the object, and its destructor informs the SS.
Right, that's exactly what weak references are.
Dec 03 2004
prev sibling parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Georg Wrede wrote:
 In article <connr8$172e$1 digitaldaemon.com>, Russ Lewis says...
 
People have suggested exactly this before.  I am going to re-read that 
page on Qt Signals (partly just because they sound interesting), but I 
think the general conclusion was that signals could be pretty well 
handled with delegates.
I can't imagine teaching delegates in the first semester. But SS I could!
Different perspectives, I guess. To me, delegates seem very straightfoward (a simple step forward from function pointers) while SS seem very advanced.
The one big problem (as I remember it) is garbage collection of objects 
which are the target of signals.
Heh, I just saw the light. What if the target object _sends a signal_ at its demise? The compiler could implicitly insert this in the destructor of SS-aware objects. From an object's point of view, all SS is about is throwing signals up in the air. If someone is interested, then fine. You neither care or even know. So yelling "I die" can be heard by the SS system itself (and whoever else might be interested).
The problem is race conditions. You have to make sure that everybody receives the "I die" signal before any more signals are dispatched, since those signals might be tied to a slot in the dying object. If you're multithreaded, it gets even worse, since this probably means that you have have to block all other signal dispatch threads (i.e. go single-threaded for a while), which becomes even harder if you have two objects dying at the same time (deadlock possibilities). Certainly, you can solve these problems. But it's a non-trivial thing, and I really don't think that non-trivial things should be done by the compiler. Do it in a library, first. Later, in 10 years or so, if we are all using signals & slots, and we all have come to a consensus about the "right" way to do them, then the next language can implement them for us more automatically. But (IMHO) we don't want to put functionality into the compiler until the programming community has come to that sort of consensus.
Dec 03 2004
parent reply Georg Wrede <Georg_member pathlink.com> writes:
In article <coq7e3$1pcb$1 digitaldaemon.com>, Russ Lewis says...
Georg Wrede wrote:
..
 From an object's point of view, all SS is about is throwing signals
 up in the air. If someone is interested, then fine. You neither care
 or even know. So yelling "I die" can be heard by the SS system itself 
 (and whoever else might be interested).
The problem is race conditions. You have to make sure that everybody receives the "I die" signal before any more signals are dispatched, since those signals might be tied to a slot in the dying object. If you're multithreaded, it gets even worse, since this probably means that you have have to block all other signal dispatch threads (i.e. go single-threaded for a while), which becomes even harder if you have two objects dying at the same time (deadlock possibilities).
I did some rethinking. If someone dies, it actually is nobody's business. So we should skip the "I die" message entirely. Have SS just check for obj != null before dispatching the signal. Nobody should be interested in whether there is anybody listening, so who cares if someone dies. Race Conditions -- how does D currently handle simultaneous calling of a method in a dying object? How, or whether, it is currently taken care of, is good enough for SS. Nothing more is needed.
Dec 03 2004
parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Georg Wrede wrote:
 In article <coq7e3$1pcb$1 digitaldaemon.com>, Russ Lewis says...
 
Georg Wrede wrote:
..
From an object's point of view, all SS is about is throwing signals
up in the air. If someone is interested, then fine. You neither care
or even know. So yelling "I die" can be heard by the SS system itself 
(and whoever else might be interested).
The problem is race conditions. You have to make sure that everybody receives the "I die" signal before any more signals are dispatched, since those signals might be tied to a slot in the dying object. If you're multithreaded, it gets even worse, since this probably means that you have have to block all other signal dispatch threads (i.e. go single-threaded for a while), which becomes even harder if you have two objects dying at the same time (deadlock possibilities).
I did some rethinking. If someone dies, it actually is nobody's business. So we should skip the "I die" message entirely. Have SS just check for obj != null before dispatching the signal.
That would require that the dying object know about all delegates which point to it, and have the ability to zero out their pointers. That's doable, but again, it's complexity better left to an (optional) library.
 Nobody should be interested in whether there is anybody listening,
 so who cares if someone dies.
 
 Race Conditions -- how does D currently handle simultaneous calling
 of a method in a dying object? How, or whether, it is currently 
 taken care of, is good enough for SS. Nothing more is needed.
Simple. We don't GC an object until all references are gone, so that never becomes an issue. If you manually delete an object, then you are responsible to have already cleaned up all of the lingering references...which is exactly like the old C/C++ way of doing things.
Dec 03 2004
parent reply Georg Wrede <Georg_member pathlink.com> writes:
In article <cor3q6$1ls$1 digitaldaemon.com>, Russ Lewis says...
Georg Wrede wrote:
..
That would require that the dying object know about all delegates which 
point to it, and have the ability to zero out their pointers.  That's 
I take it that you have connected all sending objects with delegates to all those interested in their signals? Thus, 100 sending objects emitting 10 different signals, and 100 receiving objects, each interested in all of them, gives 100*100*10 = 100_000 connections. Additionally, using delegates, every sending object would "know" the recipient? If all signals are sent via SS Dispatch, then we'd have 100*10 + 10*100 = 2000 connections, only 2% of the former. If the pointers in SS Dispatch are not reference counted, then SS objects should signal it from their destructor. A semaphore in the Dispatch table could guarantee that the destructor does not return before same-time signals have returned. BTW, the Dispatch is only interested in signal receiving objects.
doable, but again, it's complexity better left to an (optional) library.
I agree that new things should be made library, and only later considered for inclusion into the language. But I can't figure out how you could end up with a convenient syntax for SS then. Example: Of course, one could always run the code through a preprocessor, but that would be against the spirit of D, right?
 Race Conditions -- how does D currently handle simultaneous calling
 of a method in a dying object? How, or whether, it is currently 
 taken care of, is good enough for SS. Nothing more is needed.
Simple. We don't GC an object until all references are gone, so that never becomes an issue. If you manually delete an object, then you are responsible to have already cleaned up all of the lingering references...which is exactly like the old C/C++ way of doing things.
Hmm. This suggests that (if not else, then for Asserts to be possible) you can ask the GC how many references currently point to an object. Like when you think there's only one reference to an object and it turns out there are 5.
Dec 04 2004
next sibling parent "Ben Hinkle" <ben.hinkle gmail.com> writes:
"Georg Wrede" <Georg_member pathlink.com> wrote in message 
news:cosgvu$23g0$1 digitaldaemon.com...
 In article <cor3q6$1ls$1 digitaldaemon.com>, Russ Lewis says...
Georg Wrede wrote:
..
That would require that the dying object know about all delegates which
point to it, and have the ability to zero out their pointers.  That's
I take it that you have connected all sending objects with delegates to all those interested in their signals? Thus, 100 sending objects emitting 10 different signals, and 100 receiving objects, each interested in all of them, gives 100*100*10 = 100_000 connections. Additionally, using delegates, every sending object would "know" the recipient? If all signals are sent via SS Dispatch, then we'd have 100*10 + 10*100 = 2000 connections, only 2% of the former.
I don't know how SS stores the connection information so it is possible it compresses it for special cases but I would guess in reality the set of connections is not very compressable. In my experience you typically only have 0, 1 or 2 objects listening for a given signal from a given object so who cares how it compresses?
 If the pointers in SS Dispatch are not reference counted, then
 SS objects should signal it from their destructor. A semaphore
 in the Dispatch table could guarantee that the destructor does
 not return before same-time signals have returned.

 BTW, the Dispatch is only interested in signal receiving objects.

doable, but again, it's complexity better left to an (optional) library.
I agree that new things should be made library, and only later considered for inclusion into the language. But I can't figure out how you could end up with a convenient syntax for SS then. Example: Of course, one could always run the code through a preprocessor, but that would be against the spirit of D, right?
see my post using multicast delegates. I think the user code is cleaner than the SS example.
 Race Conditions -- how does D currently handle simultaneous calling
 of a method in a dying object? How, or whether, it is currently
 taken care of, is good enough for SS. Nothing more is needed.
Simple. We don't GC an object until all references are gone, so that never becomes an issue. If you manually delete an object, then you are responsible to have already cleaned up all of the lingering references...which is exactly like the old C/C++ way of doing things.
Hmm. This suggests that (if not else, then for Asserts to be possible) you can ask the GC how many references currently point to an object. Like when you think there's only one reference to an object and it turns out there are 5.
There isn't an API to ask the GC how many references point to an object. The current implementation of the GC uses a mark-sweep algorithm so it only figures out if an object has live references during the GC run and otherwise an object has no idea if it is live or not - kindof a bummer to not know if you are alive but so it goes :-) -Ben
Dec 04 2004
prev sibling parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
So you create an intermediate object between the various senders and the 
various receievers.  My argument still holds: whoever calls the 
receivers (in this case, the intermediate object) needs to get 
*immediate* notification when an object dies so as to prevent race 
conditions.

Anyhow, it seems that you're missing the point of what I wrote.  I think 
that SS sound really cool!  I would like to try them out!  But they are 
complex enough that they should not be a mandatory part of the language. 
  They should be implemented in a library for now.  Years later, if 
after long experience with it in a library, we all agree that it should 
be part of the next generation language, then we'll do it then.

Russ

Georg Wrede wrote:
 In article <cor3q6$1ls$1 digitaldaemon.com>, Russ Lewis says...
 
Georg Wrede wrote:
..
That would require that the dying object know about all delegates which 
point to it, and have the ability to zero out their pointers.  That's 
I take it that you have connected all sending objects with delegates to all those interested in their signals? Thus, 100 sending objects emitting 10 different signals, and 100 receiving objects, each interested in all of them, gives 100*100*10 = 100_000 connections. Additionally, using delegates, every sending object would "know" the recipient? If all signals are sent via SS Dispatch, then we'd have 100*10 + 10*100 = 2000 connections, only 2% of the former. If the pointers in SS Dispatch are not reference counted, then SS objects should signal it from their destructor. A semaphore in the Dispatch table could guarantee that the destructor does not return before same-time signals have returned. BTW, the Dispatch is only interested in signal receiving objects.
doable, but again, it's complexity better left to an (optional) library.
I agree that new things should be made library, and only later considered for inclusion into the language. But I can't figure out how you could end up with a convenient syntax for SS then. Example: Of course, one could always run the code through a preprocessor, but that would be against the spirit of D, right?
Race Conditions -- how does D currently handle simultaneous calling
of a method in a dying object? How, or whether, it is currently 
taken care of, is good enough for SS. Nothing more is needed.
Simple. We don't GC an object until all references are gone, so that never becomes an issue. If you manually delete an object, then you are responsible to have already cleaned up all of the lingering references...which is exactly like the old C/C++ way of doing things.
Hmm. This suggests that (if not else, then for Asserts to be possible) you can ask the GC how many references currently point to an object. Like when you think there's only one reference to an object and it turns out there are 5.
Dec 04 2004
parent Georg Wrede <Georg_member pathlink.com> writes:
In article <cot4qh$2soj$1 digitaldaemon.com>, Russ Lewis says...
Anyhow, it seems that you're missing the point of what I wrote.  I think 
that SS sound really cool!  I would like to try them out!  But they are 
complex enough that they should not be a mandatory part of the language. 

They should be implemented in a library for now.  Years later, if 
after long experience with it in a library, we all agree that it should 
be part of the next generation language, then we'll do it then.
What can I say, I'm getting convinced! Somehow this reminds me of the times everyone did their own linked lists and trees again and again. It sure took a long time for mainstream languages to render that daily chore obsolete. Actually, the only thing why I thought they should be in the language core was to get a nice syntax. But on second thought that is a minor issue.
Dec 07 2004
prev sibling next sibling parent reply pragma <pragma_member pathlink.com> writes:
I thought this sounded familiar, so I went looking.  Apparently, it's already
out there.

http://www.dsource.org/projects/dcouple/

From the Readme.txt in the svn/trunk:

The dcouple project is a place for experimenting towards an effective
implementation of the "signal and slot" call-back concept in D. As the basics
have already been illustrated by others, the main contribution of this project
will be usage issues (syntax) and performance in a garbage collected system. The
ability to break all connections to a particular slot or from a particular
signal is essential in this respect, and is reflected in the name of this
project. Hopefully, a library will result that can be included into some
"standard" library (phobos, deimos, phoenix, whatever) and form the basis of a
Qt-like GUI library. 

In article <conii3$tkv$1 digitaldaemon.com>, Georg Wrede says...
Hi!

How hard would it be to have signals&slots included in the D spec?

An intro at http://doc.trolltech.com/3.3/signalsandslots.html describes 
the idea as far as Qt is concerned, but this might be a generally useful 
thing in any OO language?

Since they have implemented this with a couple of preprocessor definitions,
it probably wouldn't be too hard to incorporate in the D language core?

Code shops usually have their staff writing stock classes between assignments,
and having signals&slots would make these classes handier to use. And large
programming projects would benefit from looser coupling between objects.

I'm not saying SS should be used _instead_ of regular object methods, just
that they add value and versatility to a class. And adding some SS to 
already existing classes could make them usable in new contexts.

(I know, I know) this might be a little too late for D 1.0. :-(

Then again, having SS in D 1.0 could make writing usable libraries easier.
By D 2.0 we'd have a real mean package!

Writing games, UI, multithreaded, real-time, control, OS, ... you name it,
SS would be of help.
- Pragma
Dec 02 2004
parent Bastiaan Veelo <Bastiaan.N.Veelo ntnu.no> writes:
Thanks, Pragma, for the introduction :-)

The status is that signals and slots as defined by dcouple are currently 
usable in single-threaded applications. The declaration of signals is a 
tad more verbose than for example Trolltech's Qt framework, but that is 
just syntactic sugar. Connecting/disconnecting them looks actually nicer 
as compared to Qt, and since signals and slots get connected more often 
than declared, we are not too far off.

I should clean up the code a bit, because there are some work-arounds in 
there for compiler limitations that have since been fixed. On the 
todo-list are thread-safety, for which I see no problems. I am also 
interested in benchmarks against C++ implementations.

The big hindrance I see before we can call dcouple a state-of-the-art 
signal and slots implementation, is run-time identification of signals 
and slots in dynamically loaded classes. This is necessary for visual 
GUI designers/builders. Other properties in the classes will also need 
this kind of RTTI. This still needs some thinking, and possibly 
extension of the D language.

A language feature that has been discussed before, called "structed 
classes" (thread "Dropping the distinction between objects and 
references may hinder performance", started 10/18/04 23:12), if it ever 
gets implemented, would take away a good deal of the current complexity 
of dcouple, and improve performance.

By all means, check out dcouple and share your thoughts!
http://svn.dsource.org/svn/projects/dcouple/trunk/managed/doc/index.html

Bastiaan.


pragma wrote:
 I thought this sounded familiar, so I went looking.  Apparently, it's already
 out there.
 
 http://www.dsource.org/projects/dcouple/
 
 From the Readme.txt in the svn/trunk:
 
 The dcouple project is a place for experimenting towards an effective
 implementation of the "signal and slot" call-back concept in D. As the basics
 have already been illustrated by others, the main contribution of this project
 will be usage issues (syntax) and performance in a garbage collected system.
The
 ability to break all connections to a particular slot or from a particular
 signal is essential in this respect, and is reflected in the name of this
 project. Hopefully, a library will result that can be included into some
 "standard" library (phobos, deimos, phoenix, whatever) and form the basis of a
 Qt-like GUI library. 
 
 In article <conii3$tkv$1 digitaldaemon.com>, Georg Wrede says...
 
Hi!

How hard would it be to have signals&slots included in the D spec?

An intro at http://doc.trolltech.com/3.3/signalsandslots.html describes 
the idea as far as Qt is concerned, but this might be a generally useful 
thing in any OO language?

Since they have implemented this with a couple of preprocessor definitions,
it probably wouldn't be too hard to incorporate in the D language core?

Code shops usually have their staff writing stock classes between assignments,
and having signals&slots would make these classes handier to use. And large
programming projects would benefit from looser coupling between objects.

I'm not saying SS should be used _instead_ of regular object methods, just
that they add value and versatility to a class. And adding some SS to 
already existing classes could make them usable in new contexts.

(I know, I know) this might be a little too late for D 1.0. :-(

Then again, having SS in D 1.0 could make writing usable libraries easier.
By D 2.0 we'd have a real mean package!

Writing games, UI, multithreaded, real-time, control, OS, ... you name it,
SS would be of help.
- Pragma
Dec 04 2004
prev sibling next sibling parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
"Georg Wrede" <Georg_member pathlink.com> wrote in message
news:conii3$tkv$1 digitaldaemon.com...
 Hi!

 How hard would it be to have signals&slots included in the D spec?

 An intro at http://doc.trolltech.com/3.3/signalsandslots.html describes
 the idea as far as Qt is concerned, but this might be a generally useful
 thing in any OO language?

 Since they have implemented this with a couple of preprocessor
 definitions,
 it probably wouldn't be too hard to incorporate in the D language core?

 Code shops usually have their staff writing stock classes between
 assignments,
 and having signals&slots would make these classes handier to use. And
 large
 programming projects would benefit from looser coupling between objects.

 I'm not saying SS should be used _instead_ of regular object methods, just
 that they add value and versatility to a class. And adding some SS to
 already existing classes could make them usable in new contexts.

 (I know, I know) this might be a little too late for D 1.0. :-(

 Then again, having SS in D 1.0 could make writing usable libraries easier.
 By D 2.0 we'd have a real mean package!

 Writing games, UI, multithreaded, real-time, control, OS, ... you name it,
 SS would be of help.
Delegates come close but they only fire a single callback instead of allowing multiple callbacks. This thread got me thinking about multicast multiple delegates. Here's the example from the supplied Qt page modified to use multi-delegates, with output: class Foo { MultiDelegate!(int) valueChanged; private int val; int value() { return val; } void value(int v) { if (val != v) { val = v; valueChanged(v); } } } import std.stdio; int main() { Foo a = new Foo; Foo b = new Foo; a.valueChanged ~= &b.value; writefln(a.value," ",b.value); b.value = 11; writefln(a.value," ",b.value); a.value = 79; writefln(a.value," ",b.value); a.valueChanged.remove(&b.value); a.value = 100; writefln(a.value," ",b.value); return 0; } output: C:\d>dmd multidg.d -version=MultiDgExample C:\dmd\bin\..\..\dm\bin\link.exe multidg,,,user32+kernel32/noi; C:\d>multidg 0 0 0 11 79 79 100 79 It's probably almost the same as other implementations only I use dynamic arrays instead of associative arrays since: 1) dynamic array take up less space and are faster and most multi-delegates will have 1 or 2 delegates attached 2) the order of execution of the delegates matches the order in which they were attached. anyhow, enjoy! -Ben begin 666 multidg.d M+RH 375L=&E$96QE9V%T93H 861D+"!R96UO=F4 86YD(&9I<F4 ;75L=&EP M;&4 9&5L96=A=&5S"B J"B J($$ ;75L=&DM9&5L96=A=&4 :7, <VEM:6QA M<B!T;R!A($,C(&UU;'1I8V%S="!D96QE9V%T92X*("H 270 :&%S(&%R<F%Y M(&-O<'D <V5M86YT:6-S('-O(&%S<VEG;FUE;G0 =VEL;"!C;W!Y('1H90H M*B!L96YG=& 86YD(&1A=&$ <&]I;G1E<B!B=70 ;6]D:69I8V%T:6]N(&-O M=6QD(&%L;&]C871E"B J(&$ 9&ES=&EN8W0 8V]P>2X 1&5L96=A=&5S(&EN M(&$ ;75L=&DM9&5L96=A=&4 87)E(&9I<F5D"B J(&EN('1H92!O<F1E<B!T M:&5Y('=E<F4 861D960N"B J"B J(%1O(&%P<&5N9"!T;R!A(&UU;'1I+61E M;&5G871E('5S92!^/0H *B!4;R!R96UO=F4 82!D96QE9V%T92!F<F]M(&$ M;75L=&DM9&5L96=A=&4 =7-E(')E;6]V92 I"B J(%1O(&9I<F4 86QL('1H M92!D96QE9V%T97, :6X ;W)D97( =7-E(&]P0V%L;#H ;75L=&ED9R I"B J M"B J(%1O(&-O;7!I;&4 =&AE(&5X86UP;&4 <G5N"B J("!D;60 ;75L=&ED M9RYD("UV97)S:6]N/4UU;'1I1&=%>&%M<&QE"B J"B J(%=R:71T96X 8GD M0F5N($AI;FML92!A;F0 <F5L96%S960 =&\ =&AE('!U8FQI8R!D;VUA:6XL M(&%S"B J(&5X<&QA:6YE9"!A="!H='1P.B\O8W)E871I=F5C;VUM;VYS+F]R M9R]L:6-E;G-E<R]P=6)L:6-D;VUA:6X*("H 16UA:6P 8V]M;65N=', 86YD M(&)U9R!R97!O<G1S('1O(&)E;BYH:6YK;&5 9VUA:6PN8V]M"B J+R *"FUO M9'5L92!M=6QT:61G.PH*=&5M<&QA=&4 1&5L96=A=&5-:7AI;B I('L*"B M+R\ 07!P96YD(&1G('1O('1H92!E;F0 ;V8 =&AE(&UU;'1I+61E;&5G871E M+ H ("\O($EF(&1G(&ES(&YU;&P ;F]T:&EN9R!C:&%N9V5S+ H ('9O:60 M*2!R971U<FX["B ("!B;V]L(&9O=6YD(#T 9F%L<V4["B ("!I;G0 ;&5N M(#T 9&=S+FQE;F=T:#L*(" (&EN="!N(#T ;&5N+3$["B ("!W:&EL92 H M;B ^/2 P("8F(&1G<UMN72!I<R!N=6QL*0H (" (" M+6X["B ("!I9B H M;B \(&QE;BTQ*0H (" ("!D9W-;;BLQ72 ](&1G.PH (" 96QS90H (" M("!D9W, ?CT 9&<["B ?0H*(" O+R!296UO=F4 =&AE(&9I<G-T(&]C8W5R M86YC92!O9B!D9R!F<F]M('1H92!M=6QT:2UD96QE9V%T92X*(" O+R!)9B!D M9R!I<R!N;W0 :6X =&AE(&UU;'1I+61E;&5G871E(&YO=&AI;F< 8VAA;F=E M96YG=& /3T ,"D <F5T=7)N.PH (" 8F]O;"!F;W5N9" ](&9A;'-E.PH M(" 9F]R("AI;G0 ;CTP(#L ;B \(&1G<RYL96YG=& M,3L *RMN*2!["B M(" (&EF(" A9F]U;F0 )B8 9&=S6VY=(&ES(&1G*2!F;W5N9" ]('1R=64[ M"B (" (&EF("AF;W5N9"D 9&=S6VY=(#T 9&=S6VXK,5T["B (" (&EF M("AD9W-;;ET :7, ;G5L;"D 8G)E86L["B ("!]"B ("!I9B H9F]U;F0 M?'P 9&=S6VQE;F=T:"TQ72!I<R!D9RD*(" (" 9&=S6VQE;F=T:"TQ72 ] M(&YU;&P["B ?0H*(" O+R!T:&4 87)R87D ;V8 9&5L96=A=&4 =VET:"!P M;W-S:6)L92!T<F%I;&EN9R!N=6QL<PH ($-A;&QB86-K6UT 9&=S.R *?0H* M+R\ 375L=&E$96QE9V%T92!W:71H(&YO(&%R9W,*<W1R=6-T($UU;'1I1&5L M96=A=&4H*2!["B 86QI87, =F]I9"!D96QE9V%T92 I($-A;&QB86-K.PH M(&UI>&EN($1E;&5G871E36EX:6XA*"D["B =F]I9"!O<$-A;&PH*2!["B M<R!N=6QL*2!B<F5A:SL*(" (" 9&<H*3L*(" ('T*("!]"GT*"B\O($UU M;'1I1&5L96=A=&4 =VET:"!O;F4 87)G"G-T<G5C="!-=6QT:41E;&5G871E M("AD9R!I<R!N=6QL*2!B<F5A:SL*(" (" 9&<H87)G*3L*(" ('T*("!] M"GT*"B\O($UU;'1I1&5L96=A=&4 =VET:"!T=V\ 87)G<PIS=')U8W0 375L M96%C:" 0V%L;&)A8VL 9&<[(&1G<RD >PH (" ("!I9B H9&< :7, ;G5L M;"D 8G)E86L["B (" (&1G*&%R9S$L87)G,BD["B ("!]"B ?0I]" HO M+R!-=6QT:41E;&5G871E('=I=& =&AR964 87)G<PIS=')U8W0 375L=&E$ M87)G,2Q4,B!A<F<R+%0S(&%R9S,I($-A;&QB86-K.PH (&UI>&EN($1E;&5G M(&%R9S,I('L*(" (&9O<F5A8V H($-A;&QB86-K(&1G.R!D9W,I('L*(" M(" :68 *&1G(&ES(&YU;&PI(&)R96%K.PH (" ("!D9RAA<F<Q+&%R9S(L M87)G,RD["B ("!]"B ?0I]" HO+R!-=6QT:41E;&5G871E('=I=& 9F]U M<B!A<F=S"G-T<G5C="!-=6QT:41E;&5G871E*%0Q+%0R+%0S+%0T*2!["B M('L*(" (&9O<F5A8V H($-A;&QB86-K(&1G.R!D9W,I('L*(" (" :68 M*&1G(&ES(&YU;&PI(&)R96%K.PH (" ("!D9RAA<F<Q+&%R9S(L87)G,RQA M<F<T*3L*(" ('T*("!]"GT*"G9E<G-I;VX *$UU;'1I1&=%>&%M<&QE*2![ M"B +RHJ($5X86UP;&4 8VQA<W, :6QL=7-T<F%T:6YG(&UU;'1I+61E;&5G M871E<R!B87-E9"!O;B!1="=S(&5X86UP;&4 870*(" *B ("!H='1P.B\O M9&]C+G1R;VQL=&5C:"YC;VTO,RXS+W-I9VYA;'-A;F1S;&]T<RYH=&UL"B M("H ( H (" J+PH (&-L87-S($9O;R!["B ("!-=6QT:41E;&5G871E(2AI M;G0I('9A;'5E0VAA;F=E9#L*(" ('!R:79A=&4 :6YT('9A;#L*(" (&EN M="!V86QU92 I('L*(" (" <F5T=7)N('9A;#L*(" ('T*(" ('9O:60 M=F%L=64H:6YT('8I('L*(" (" :68 *'9A;" A/2!V*2!["B (" (" M=F%L(#T =CL*(" (" ("!V86QU94-H86YG960H=BD["B (" ('T*(" M('T*("!]" H (&EM<&]R="!S=&0N<W1D:6\["B :6YT(&UA:6XH*2!["B M("!&;V\ 82 ](&YE=R!&;V\["B ("!&;V\ 8B ](&YE=R!&;V\["B ("!A M+G9A;'5E0VAA;F=E9"!^/2 F8BYV86QU93L*(" ('=R:71E9FQN*&$N=F%L M;&XH82YV86QU92PB("(L8BYV86QU92D["B ("!A+G9A;'5E(#T -SD["B M:&%N9V5D+G)E;6]V92 F8BYV86QU92D["B ("!A+G9A;'5E(#T ,3 P.PH M(" =W)I=&5F;&XH82YV86QU92PB("(L8BYV86QU92D["B ("!R971U<FX ),#L*("!]"GT* ` end
Dec 04 2004
parent Georg Wrede <Georg_member pathlink.com> writes:
In article <cosich$255j$1 digitaldaemon.com>, Ben Hinkle says...
"Georg Wrede" <Georg_member pathlink.com> wrote in message
news:conii3$tkv$1 digitaldaemon.com...
 Hi!

 How hard would it be to have signals&slots included in the D spec?
output: C:\d>dmd multidg.d -version=MultiDgExample C:\dmd\bin\..\..\dm\bin\link.exe multidg,,,user32+kernel32/noi; C:\d>multidg 0 0 0 11 79 79 100 79 It's probably almost the same as other implementations only I use dynamic arrays instead of associative arrays since: 1) dynamic array take up less space and are faster and most multi-delegates will have 1 or 2 delegates attached 2) the order of execution of the delegates matches the order in which they were attached. anyhow, enjoy! -Ben
Cool code! I'll use this.
Dec 07 2004
prev sibling parent reply Dr.Dizel <Dr.Dizel_member pathlink.com> writes:
In article <conii3$tkv$1 digitaldaemon.com>, Georg Wrede says...
How hard would it be to have signals&slots included in the D spec?
Hi! Walter is in trouble because he has two "twins" in D: function pointers and delegates. He doesn't know what to do with them. He doesn't understand S&S well, they OOP-ish and power. There is must be delegates and S&S instead of function pointers and delegates. But Walter still love C too much... shame! He froze any move in this way. :-(
Dec 05 2004
next sibling parent Bastiaan Veelo <Bastiaan.N.Veelo ntnu.no> writes:
Dr.Dizel wrote:
 In article <conii3$tkv$1 digitaldaemon.com>, Georg Wrede says...
 
How hard would it be to have signals&slots included in the D spec?
Hi! Walter is in trouble because he has two "twins" in D: function pointers and delegates. He doesn't know what to do with them. He doesn't understand S&S well, they OOP-ish and power. There is must be delegates and S&S instead of function pointers and delegates. But Walter still love C too much... shame! He froze any move in this way. :-(
Sorry Dizel, you must be trolling.
Dec 09 2004
prev sibling parent John Reimer <brk_6502 yahoo.com> writes:
Dr.Dizel wrote:

 In article <conii3$tkv$1 digitaldaemon.com>, Georg Wrede says...
How hard would it be to have signals&slots included in the D spec?
Hi! Walter is in trouble because he has two "twins" in D: function pointers and delegates. He doesn't know what to do with them. He doesn't understand S&S well, they OOP-ish and power. There is must be delegates and S&S instead of function pointers and delegates. But Walter still love C too much... shame! He froze any move in this way. :-(
Function pointers are still very useful for interfacing with C projects. They serve a different purpose than delegates. I think you're hacking away at a straw man.
Dec 09 2004