I felt inspired by the "Polymorphic IF" and the "non-deterministic REBOL"
threads, so I decided to whip up a state machine in REBOL. Here it is:

Machine: make object! [
    _State: word!
    State: func [][_State]
    Goto: func ['Next [word!]][
        _State: Next
        ]
    Start: func ['Initial [word!]][
        _State: Initial
        ]
    Run: func [][
        while [_State][
            try [do State true]
            ]
        ]
        Stop: func [][
        _State: false
        ]
    Stop
    ]

na: 0
nb: 0

a: func [] [
    na: na + 1 print ["na:" na] Machine/Goto b
    ]

b: func [] [
    nb: nb + 1 print ["nb:" nb]
    either nb < 10 [
        Machine/Goto a
        ][
        Machine/Stop
        ]
    ]

Machine/Start a

Enjoy!

Andrew Martin
Waiting for REBOL/View...
ICQ: 26227169
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
-><-

Reply via email to