Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Any FSM fans?

From: g:santilli:tiscalinet:it at: 3-Nov-2001 15:20

Hello Gregg! On 02-Nov-01, you wrote: Just a note, GI> switch state [ GI> locked [ GI> switch event [ GI> coin [ GI> do-unlock GI> state: unlocked GI> ] GI> pass [ GI> alarm GI> state: locked GI> ] GI> ] GI> unlocked [ GI> switch event [ GI> coin [ GI> do-lock GI> state: locked GI> ] GI> pass [ GI> thank-you GI> state: unlocked GI> ] GI> ] GI> ] An efficient way to do this in REBOL (which I used in the past to implement FSMs) could be the following: states: context [ locked: context [ coin: does [ do-unlock state: unlocked ] pass: does [ alarm ; redundant, could be avoided state: locked ] ] unlocked: context [ coin: does [ thank-you ; redundant, could be avoided state: unlocked ] pass: does [ do-lock state: locked ] ] ] state: states/locked ; ... state/coin ; etc... GI> Whew! Anybody still awake? :) Yup. ;-) Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/