is a mechanism for portably determining the availability of
cond-expand special form conditionally expands according to
the features available.
Each clause has the form(feature-requirement expression ...)
where feature-requirement can have one of the following forms:feature-identifier (and feature-requirement ...) (or feature-requirement ...) (not feature-requirement) else
(Note that at most one
elseclause may be present, and it must always be the last clause.)
cond-expandspecial form tests for the existence of features at macro-expansion time. It either expands into the body of one of its clauses or signals an error during syntactic processing.
cond-expandexpands into the body of the first clause whose feature-requirement is currently satisfied (an
elseclause, if present, is selected if none of the previous clauses is selected).
A feature-requirement has an obvious interpretation as a logical formula, where the feature-identifier variables have meaning true if the feature corresponding to the feature-identifier, as specified in the SRFI registry, is in effect at the location of the
cond-expandform, and false otherwise. A feature-requirement is satisfied if its formula is true under this interpretation.(cond-expand ((and srfi-1 srfi-10) (write 1)) ((or srfi-1 srfi-10) (write 2)) (else)) (cond-expand (command-line (define (program-name) (car (argv)))))
The second example assumes that
command-lineis an alias for some feature which gives access to command line arguments. Note that an error will be signaled at macro-expansion time if this feature is not present.
Note that MIT/GNU Scheme allows
cond-expandin any context where a special form is allowed. This is an extension of the semantics defined by SRFI 0, which only allows
cond-expandat top level.