[GUI] CGA standard

Krasimir Angelov ka2_mail@yahoo.com
Sun, 16 Mar 2003 12:10:03 -0800 (PST)


Dear Haskellers,

     After a long absence I again have the chance to
follow the discussions in the forums. And now I would
like to express my personal opinion. 
     A lot of attention is paid to the way of
realizing the multithreading in CGA. I totally agree
that the choice of concrete abstraction for
multithreading is a little bit out of the CGA
standard. The callback functions are simple and
effective way of realizing the event handling. This
mechanism doesn’t require but also doesn’t exclude the
usage of threads. The stream-based library can be
developed later on top of callback functions. In order
to realize multithreading all library primitives
should be thread safe. Primitives whose execution
require a long period of time (i.e. the primitives
that start event-loop or directly/indirectly execute
the callback functions in Haskell) should not block
the execution of the concurrent threads. The way of
realizing it depends on the used compiler. For the
future versions of GHC probably the best way will be
by using ‘threadsafe’ foreign calls, but for Hugs
maybe the  ‘yield’ primitive. That’s why I propose not
to specify the exact way of multithreading. AS for the
realization, it can be done in a different way for the
different combinations compiler/toolkit. 
 	Another point that I noticed is the way of
registering/unregistering of the event handlers. Under
Windows all events are passed to the function handler
even if it ignores them. Under GTK the event is passed
only if there is a registered event handler. All
libraries based on X have similar design because this
allows minimizing of the traffic between the
application and the X server. It is a disadvantage of
the GTK based Port library where all event handlers
are automatically registered even if they are ignored
by the Haskell program. It is not difficult to correct
this, but we have to bear it in mind when making the
standard.
	Summary:
           - CGA should use callback functions for
event handling
           - All primitives should be thread safe
           - Calling whoever of the primitives should
not block the concurrent threads. An exception can be
done only for the primitives who are executed in a
very short constant time
           - For each event there should be two
functions: register and unregister

	I am under the impression that there is a consensus
of all points mentioned above but they have to be
specified in the standard. In this context I would
like to ask whether there are any additions to the
document that Axel wrote.

Best wishes,
Krasimir

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com