Something unspeakable. "Raw" gotos that need to be structured as a case object.
Note: the enum vanishes in the C backend and becomes goto Label
type MyState = enum
A, B, C
proc stateMachine() =
var state {.goto.} = A
case state
of A:
doSomething()
if sample([0, 1]) == 1: # throw a coin
state = B # goto B
else:
state = C
of B:
doSomethingElse()
state = A # go back to A
of C:
doLots()
# exit
Run
- Performing goto in Nim sls1005
- Performing goto in Nim Hlaaftana
- Performing goto in Nim sls1005
- Performing goto in Nim xigoi
- Performing goto in Nim Araq
- Performing goto in Nim reneha
- Performing goto in Nim PMunch
- Performing goto in Nim elcritch
- Performing goto in Nim mratsim
- Performing goto in Nim coffeepot
- Performing goto in Nim mratsim
- Performing goto in Nim Araq
