(use-modules (sly coroutine))
Coroutines are the building block for cooperative multitasking. When used with agendas, they are a powerful mechanism for writing algorithms that span multiple clock ticks in a straightforward, linear fashion. Sly’s coroutines are built on top of Guile’s delimited continuations, called prompts.
To run a procedure as a coroutine, use the call-with-coroutine
procedure. Once inside the coroutine prompt, the yield
procedure can be used to pause the procedure and pass its continuation
to a callback procedure. The callback may call the continuation at
its convenience, resuming the original procedure.
Coroutines are particularly useful in conjunction with Agendas.
Apply thunk within a coroutine prompt.
Evaluate body within a coroutine prompt.
Syntacic sugar for a lambda
expression whose body is run
within a coroutine prompt.
Syntacic sugar for defining a procedure called name with formal arguments formals whose body is run within a coroutine prompt.
Syntacic sugar for defining a procedure called name with optional and keyword arguments formals whose body is run within a coroutine prompt.
Yield continuation to the procedure callback.