Node:SRFI-0, Next:SRFI-1, Previous:About SRFI Usage, Up:SRFI Support
SRFI-0 defines a means for checking whether a Scheme implementation has
support for a specified feature. The syntactic form
which implements this means, has the following syntax.
<cond-expand> --> (cond-expand <cond-expand-clause>+) | (cond-expand <cond-expand-clause>* (else <command-or-definition>)) <cond-expand-clause> --> (<feature-requirement> <command-or-definition>*) <feature-requirement> --> <feature-identifier> | (and <feature-requirement>*) | (or <feature-requirement>*) | (not <feature-requirement>) <feature-identifier> --> <a symbol which is the name or alias of a SRFI>
When evaluated, this form checks all clauses in order, until it finds one whose feature requirement is satisfied. Then the form expands into the commands or definitions in the clause. A requirement is tested as follows:
andform, all requirements must be satisfied. If no requirements are given, it is satisfied, too.
orform, at least one of the requirements must be satisfied. If no requirements are given, it is not satisfied.
notform, the feature requirement must not be satisfied.
elseand it is the last clause, it is satisfied if no prior clause matched.
If no clause is satisfied, an error is signalled.
cond-expand is needed to tell what a Scheme implementation
provides, it must be accessible without using any
implementation-dependent operations, such as
Guile. Thus, it is not necessary to use any module to get access to
Currently, the feature identifiers
srfi-0 are supported. The other SRFIs are not in that list by
default, because the SRFI modules must be explicitly used before their
exported bindings can be used.
So if a Scheme program wishes to use SRFI-8, it has two possibilities:
First, it can check whether the running Scheme implementation is Guile,
and if it is, it can use the appropriate module:
(cond-expand (guile (use-modules (srfi srfi-8))) (srfi-8 #t)) ;; otherwise fail.
The other possibility is to use the
--use-srfi command line
option when invoking Guile (see Invoking Guile). When you do that,
the specified SRFI support modules will be loaded and add their feature
identifier to the list of symbols checked by
So, if you invoke Guile like this:
$ guile --use-srfi=8
the following snippet will expand to
(cond-expand (srfi-8 'hooray))