Help with coroutine-based state machines?
Alan Kennedy
alanmk at hotmail.com
Fri May 30 07:56:47 EDT 2003
Yair Chuchem wrote:
> How about this implemetation of your state-machine, without the
> cluttering of the while loops, and as a side effect, without use
> of generators too:
[extremely clear example elided]
> Is there something I'm missing?
No, obviously something I'm missing :-)
Yours is hopefully the sort of solution I would have arrived at
for my original problem if I had really actually thought the problem
all the way through, and designed it myself, rather than go looking
for pre-cooked recipes.
I fully recognise that my design for a state machine could be
considered overblown. I suppose that what fired my enthusiasm was
that during the process of developing my design, I inadvertently
stumbled on the realisation of what coroutines were, which was
much more fun than state machines ;-)
Thanks also to Neil Schemenauer and Stephen Taschuk for providing
several alternatives which are just as clean as Yairs, and also
don't need coroutines or generators.
Particularly I have taken on board Stephen's advice re using generators
to avoid the need for state machines, and also that the same
suspend/resume functionality can be implemented by simply having a
yield in the dispatch function.
kind regards,
--
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan: http://xhaus.com/mailto/alan
More information about the Python-list
mailing list