srfi.190
- Coroutine generators ¶This module provides a macro, coroutine-generator
,
that simplifies defining a generator-based coroutine.
[SRFI-190]{srfi.190
}
Returns a generator procedure. When called first,
the created generator procedure executes body from the beginning.
If a syntax yield
appears within body, it is evaluated to
the yielding procedure. When the yielding procedure is called, the
continuation of the rest of body is saved and the control returns
to the caller of the generator. When the generator is called again,
it resumes from the saved continuation. If body evaluates to the
last expression, it’s the end of generator and the generator returns EOF.
The coroutine-generator
expression can be similary expressed
with make-coroutine-generator
(see Generator constructors),
by explicitly introducing a variable bound to the yielding procedure:
(make-coroutine-generator (lambda (yield) body ...))
The difference is that, with this SRFI, yield is not a lexically bound variable, but rather a syntax parameter (see Syntax parameters).
[SRFI-190]{srfi.190
}
A syntax parameter that evaluates to the yielding procedure
within coroutine-generator
. It is an error if it appears outside of
the body of coroutine-generator
.