

Link: http://codepad.org/IiqI56ti raw code | fork ]



C++ , pasted on May 24:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 void Next ( state ) { switch ( state ) { case INITIAL: Thing1 (); break ; case THING1: Thing2 (); break ; case THING2: Thing3 (); break ; case THING3: // do nothing -- exit break ; } } void DoThing1 () { // Do "thing 1" Next ( THING1 ); } void DoThing2 () { // Do "thing 2" Next ( THING2 ); } void DoThing3 () { // Do "thing 3" Next ( THING3 ); }