Emit
Generator output: yieldValue performs a Yield, and the generator handler reifies the continuation as data. The program becomes a Generator value: Generator.Finished with the result, or Generator.Yielded holding the value and the rest of the program as a callable continuation. The driver decides when, and whether, to resume; in between, the suspended program is just data:
var step = countdown.generator<Int, String>().runOrThrow()
while (step is Generator.Yielded) {
println(step.value)
step = step.resume().runOrThrow()
}Content copied to clipboard