Re: Callback-related libraries and terminology
werasm wrote:
Scott Meyers wrote:
Also, does anybody know where the name "slot" comes from in
this context? I've found this term to be a stumbling block
for trying to understand this stuff.
I think the name "slot" originates from the Qt GUI Framework.
They used a signal-slot mechanism to interface to events that
the client of a widget needed to respond too. Similarly to
Borland's Closures.
This snippet is from their documentation:
"In Qt we have an alternative to the callback technique. We use signals
and slots. A signal is emitted when a particular event occurs. Qt's
widgets have many pre-defined signals, but we can always subclass to
add our own. A slot is a function that is called in reponse to a
particular signal. Qt's widgets have many pre-defined slots, but it is
common practice to add your own slots so that you can handle the
signals that you are interested in."
I would define the signal as the "callable entity" and the
slot as the "executable entity". The lost exists at the
execution sight, whereas the signal exists at the callsight.
I would avoid the word "signal", as it has other meanings in C++
(and C). What's wrong with the classic terms event or notifier,
and handler or callback?
Slots are basically the callback that gets called in response
to a signal (event).
An asynchronous callback, in sum. Or a handler.
The mechanism IM(h)O is very similar to GOFS command pattern
which I personally prefer at this moment. A signal is emitted,
and all slots bounded to that signal is called, so to speak
(Macro-command is executed, and all the children bounded to it
is executed).
An event forwarding discriminator?
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]