Transfers control from the current coroutine back to the caller (when the
sym
tag is not given), or to some other coroutine (specified by
sym
) to continue execution at the point where that coroutine had
called yield
before. In the first case, the value any
will be returned from the corresponding co
call, in the second case it will be the return
value of that yield
call. See also stack
, catch
and throw
.
: (co "rt1" # Start first routine
(msg (yield 1) " in rt1 from rt2") # Return '1', wait for value from "rt2"
7 ) # Then return '7'
-> 1
: (co "rt2" # Start second routine
(yield 2 "rt1") ) # Send '2' to "rt1"
2 in rt1 from rt2
-> 7