[mercury-users] Event handling in mercury
Holger Krug
hkrug at rationalizer.com
Mon Jul 16 17:12:17 AEST 2001
The main control structure of contemporary application programs,
distinguished by more or less complicated graphical user interfaces,
is the event loop. In mercury-extras/graphics/samples/calc/ the event
loop is implemented in a rather crude way, not acceptable for industry
use:
After each event occurring the changed application state is forwarded
to each of the widgets by redefining the event handler for every
possible future event.
This seems to be as well an unnecessarily strange coding style as also
highly inefficient, at least in a strict language like mercury.
Obviously a global application state could be implemented in Mercury
by using mercury-extras/references/, but that's not what one should be
happy with, when starting to work with Mercury.
So why not to add global state handling to the Mercury libraries in a
way which seems to conform with the fundamentals of the Mercury
language:
:- module gstore. % compare module store
:- interface.
:- import_module store. % type store__mutvar(T,S).
:- import_module io. % type io__state.
:- type gstore (S).
:- some [S] pred gstore__new(gstore(S),io__state,io__state).
:- mode gstore__new(out, di, uo) is det.
:- pred gstore__new_mutvar(T,mutvar(T,S), gstore(S), io__state, io__state).
:- mode gstore__new_mutvar(in, out, in, di, uo) is det.
:- pred gstore__get_mutvar(mutvar(T,S), T, gstore(S), io__state, io__state).
:- mode gstore__get_mutvar(in, out, in, di, uo) is det.
:- pred gstore__set_mutvar(mutvar(T,S), T, gstore(S), io__state, io__state).
:- mode gstore__set_mutvar(in, in, in, di, uo) is det.
% etc.
--
Holger Krug
hkrug at rationalizer.com
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list