-
Yorick Peterse authored
Early block returns are required in order to break out of tail recursive methods. For example, Block.while_true would be implemented as follows: impl Block { def while_true(block: ()) -> Nil { call.if_false { return } block.call while_true(block) } } Without the ability to perform an early return this method would never return. Block returns act much like Smalltalk's block returns: they return to the scope that defined the block. Internally this works by taking the Binding of the current scope, finding it's top-most parent, then unwinding until we reach the execution context that uses this binding. I opted for extending the VM's "Return" instruction instead of adding a separate one as otherwise a lot of logic would have to be duplicated.