ANNOUNCE ex11 release two

Joe Armstrong <>
Thu Jan 22 14:37:55 CET 2004


On Thu, 22 Jan 2004, Vlad Dumitrescu wrote:

> Hi again,
> 
> I suppose that the use of callbacks will not remain as it is now: the fun is
> evaluated in the main loop of the widget. I think it should either be spawned,
> or the mechanism be replaced with message sending to an owner-process (like in
> gs, IIRC)

On the contrary I think this is *exactly* how it should be done.

I have experimented with many different styles of callback handling
and IMHO this is the best. If you want to do it with messages you can write 
your top-level thing like this:

	B = swButton:make(Win ......)
	S = self(),
	B ! {onClick, fun(X) -> S ! {wrapper, X} end},
	...

	loop(...).

        
        loop(...) ->
	   receive
		{wrapper, X} ->
		    Do something
	        ...
	   end

Note the Fun is evaluated in the main  loop of the widget NOT in the
application and NOT in the driver.

  I have totally re-written the  widget libraries at least five times,
and feel this structure is best.

  If you don't do it like this life gets difficult. Suppose you make a
top level  window with  20 widgets  in it. You  don't want  to forward
messages from all the widgets to the top-level controller, only a few
of them - so you set up callbacks within the individual widgets.

  If you did want all the messages you just make the funs send messages
to the required process as in the example above.

  Cheers

  /Joe







More information about the erlang-questions mailing list