For Development HEAD DRAFTSearch (procedure/syntax/module):

11.43 srfi.190 - Coroutine generators

Module: srfi.190

This module provides a macro, coroutine-generator, that simplifies defining a generator-based coroutine.

Macro: coroutine-generator body …

[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).

Macro: yield

[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.

Macro: define-coroutine-generator name body …
Macro: define-coroutine-generator (name . formals) body …

[SRFI-190]{srfi.190} These are shorthand of the following:

(define name (coroutine-generator body ...))

(define (name . formals) (coroutine-generator body ...))


For Development HEAD DRAFTSearch (procedure/syntax/module):
DRAFT