(yield (? v #n)) v: any type (optional)
S
Yields a value from a coroutine.
When a yield
form is evaluated, the coroutine is paused, yielding v
. When
coro-run
is used to resume execution of the coroutine, the yield
form
finishes evaluating, returning the argument which was passed to coro-run
.
It's an error if yield
is called without an enclosing fn
form - for example,
at the toplevel of a source file.
The presence of a yield
form in the body of a fn
form is what differentiates a
coroutine function from a normal function. When a coroutine
function is called, it returns a new coroutine which is paused at the
beginning of the function's body.