Loop exits

  loop_exit = `exit' <exit>

Consider the while_loop method of the lazy class:

  func while_loop(self, loop_body : Lazy) -> Entity
    result := Undefined
    repeat
      cond := value(self)
      exit when cond /= boolean.True
      result := value(loop_body)
    loop

To exit early from this loop, the evaluation of the loop body must return immediately when the exit instruction is executed and it must set some sort of flag that the while_loop method can check. For example:

  func while_loop(self, loop_body : Lazy) -> Entity
    result := Undefined
    repeat
      cond := value(self)
      exit when cond /= boolean.True
      result := value(loop_body)
    until global.Must_exit_flag = True
    global.Must_exit_flag := False

When the loop body is translated, it suffices to translate an exit instruction into an assignment to the global flag, followed by a return instruction. If it is interpreted, the routine executing the sequence of instructions should check the flag after every instruction.

Multi-level exits can be modeled by using a global counter instead of a global flag.