Version française
Home     About     Download     Resources     Contact us    
Browse thread
Does LablTk have a future?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Re: Feeding the OCaml GUI troll
On Wed, 2005-08-31 at 22:49 -0600, Matt Gushee wrote:

> I'm not sold on the idea of a "simple" GUI front end.

I am. My idea is this: GET RID OF CALLBACKS.
The idea is to use (user space) threads instead.

The big problem with GUI's is that they're passive.
You write 'event handlers' and have to store the current
state manually. By control inverting the code, you can
just use a thread for each widget.

For example for a button something like:

	let rec wait_down () =
		read event;
		match event with
		| state_request -> 
			send(up); 
			wait_down()
		| click -> wait_up()

	and wait_up () =
		draw_button_down();
		read event;
		match event with
		| state_request -> 
			send(down); 
			wait_up()
		| click ->
			draw_button_up()
			wait_down()


is purely functional: it uses the program counter
to maintain state, instead of a mutable state variable.		

-- 
John Skaller <skaller at users dot sourceforge dot net>