View Single Post
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 04-19-2007, 09:14 AM

I can't explain why the sarah file fails and the latest one that you provided doesn't fail but I believe that it is simply a matter of chance. After numerous conversations with DrJim I have tentatively concluded the following:

At least two of the while events (and probably all of them) are inherently unstable. The liklihood of failure is enhanced if the method that handles the while event contains a doTogether block but I doubt that is a requirement for failure.

When I first became aware of this event type, my initial incorrect assumption was that when the specified state becomes true, the handler method is called. When the method returns, if the specified state is still true, the method is called again. If the specified state is not true when the handler method returns, the handler is not called again. I think that was a bad assumption.

I believe I can demonstrate that this is not the case. It appears that when the specified state goes false, the handler method is somehow forced to abort almost immediately without being given an opportunity to clean up after itself. (Possibly the thread that the handler method is running on is simply stopped.) Sometimes this results in a runtime error and sometimes it doesn't. I doubt that it is possible to write a process of any substance that can simply be forced to abort at any time without causing problems some of the time. There is a lot of chance involved at this point. Regardless, if this is the actual behavior of the while event, this is a bad program design.

Maybe the purpose of the begin and end phases of the while event is to make it possible for the programmer to write the handler method in such a way that it knows how to clean up after itself when forced to terminate, but without documentation, I have been unable to figure out a way to do this.

On the basis of the above, a second tentative conclusion of mine is that the programmer should probably avoid using the during phase of the while events. Rather, the begin phase could be used to cause a well designed method to begin execution, probably using an infine loop to continue executing the desired process until the end phase sets a flag telling the process to terminate. When that flag is set, the process should clean up after itself and terminate as quickly as possible but not until it has cleaned up after itself.

But then again, I'm relatively new to Alice and I may have this all wrong.

Dick Baldwin

Last edited by DickBaldwin; 04-19-2007 at 02:05 PM. Reason: Clarification
   
Reply With Quote