lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, 2010-01-13 at 15:44 +0100, David Kastrup wrote:
> Wesley Smith <wesley.hoke@gmail.com> writes:
> >> Tail calls are good for state machines.
> >> ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-443.pdf
> >
> > I find coroutines more elegant.
> 
> Yup.  Nothing beats using the instruction pointer and dynamic state as
> state variable.
> 

Ok, hit me with a spoon, can anyone post an example of using coroutines
to implement a state machine?

I guess each state is a coroutine, and transitions are yields and
resumes, but the details escape me.

Jorge