At 08:36 PM 5/14/2004, you wrote:
Now that I have (I think) a reasonable solution to the segmenting problem
(a rather nifty extension to cproto for a different purpose which happens
to extend quite well to the problem of assigning functions to segments),
I've decided to get serious about porting my project, CalcRogue, to
PalmOS. But first, there's a rather fundamental architecture issue which
is bothering me.

   WHY does everyone put the event loop at the base of the call stack?

Seems to me, it makes a lot more sense to write as one would a curses
program with blocking input, only instead of calling getch(), call a
function with the event loop in it. On getting a keypress, return from the
event loop with the key; and if forced to quit, do it using a nonlocal
return. But I've never seen it done this way, even when porting programs
written with lots of blocking input.

So why does no one do this? Am I missing something?

That's not a standard structure for an event-driven program. Most PDA apps aren't descended from character driven keyboard applications; instead they're closer to Mac OS or Win32 applications where the program exists as a set of services that are configured and activated by user input.


There's nothing that says your method won't work, but its much harder to write an open-ended program using that architecture. For example, how do you handle menus in that system? The current architecture models the program as a stack of forms, each form having a set of objects, all of which can be acted on using a set of APIs or managers.

Also, on event-driven systems, not all events are for your program. Palm OS sends a number of events that just pass through the event loop briefly before getting used by SysHandleEvent -- this is done to give applications a chance to intercept those (a way of extending the system), as well as a way to have parts of the OS not have to know where event come from -- they get posted to a queue, and at some future time, the OS pulls them out of a queue.

Of course, even with event driven systems, there are roles for local event loops. For example, when you popup a list with LstPopupList, the system actually enters a private event loop that handles the pen and navigation keys until a selection has been made or the list has been cancelled. There's also a local event loop used for FrmDoDialog, since that lets your application have the appearance of just calling a subroutine and getting data (the filled-out form and button used to close the form) returned to it.

-- Ben Combee, DTS technical lead, PalmSource, Inc.
   Read "Combee on Palm OS" at http://palmos.combee.net/



--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to