From: John Carter Date: 2006-09-11T06:34:28+09:00 Subject: Re: state machine in ruby First off I would just like to note a small mathematical congruence.... Every state machine can be replaced by a Thread. ie. Instead of a tangly state machine, you have a thread sucking on an event queue. Sometimes I find that really cleans things up. Now add Ruby Exception classes and rescues into the mix and the picture can start to get quite rosy. Another wild off the wall trick I have used with great success several times in my life.... Translate the events into char's. Then an event stream is a string. Then a Regexp is a very very powerful, terse and expressive way of recognizing exceedingly complex event streams. John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : john.carter@tait.co.nz New Zealand "We have more to fear from The Bungling of the Incompetent Than from the Machinations of the Wicked." (source unknown)