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

Reply via email to