bounce method

T bounce()

Runs the function, "bouncing" on the recursion trampoline, returning the result of the wrapped computations.

Implementation

T bounce() {
  var result = this;

  while (true) {
    switch (result) {
      case _Value(:final value):
        return value;
      case _Instruction(:final call):
        result = call();
    }
  }
}