[GUI] The register/unregister callbacks issue

Alastair Reid alastair@reid-consulting-uk.ltd.uk
Wed, 19 Mar 2003 14:51:31 +0000


Peter Achten <peter88@cs.kun.nl> writes:

> In my opinion a programmer should not have to register/unregister
> callbacks explicitly.

I don't understand what you're proposing in its place.  

You say that on X you do need to [un]register callbacks and on Windows
you use a filter function to determine whether or not to use the
callback.  Either way, it seems that there is some mechanism which
lets the backend (windows, X, Motif, etc) know that you no longer need
to receive events of that type so the API is going to have to provide
appropriate functions.  That is, there will be a way to register to
receive those events and a way to stop receiving those events.
Whether they register and unregister a callback or change a bitset
defining which events to receive or do something else is largely
irrelevant.

--
Alastair Reid                 alastair@reid-consulting-uk.ltd.uk  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/

ps The discussion of the cost of receiving mouse events seems to
provide an argument against using streams of events as the base on
which other APIs are implemented.  If programs explicitly register for
events/callbacks, then we can avoid the cost of propagating events
that aren't wanted.  If the GUI simply spouts a stream of timestamped
event objects as in Fran-like systems, then we have to propagate
events which aren't needed because there's no easy way to know what
events are wanted.  (A stream-based system could have operations to
turn certain events on and off but this leads to a difficult
programming style where you have to coordinate your pure event-stream
amnipulation code with your monadic event on/off code.)  This isn't to
say that streams are a bad model simply that they can't express
something that the monadic models can.