Next: srfi cond-expand vicare, Previous: srfi cond-expand rationale, Up: srfi cond-expand [Index]
Syntax:
<command or definition>
--> <command>
| <definition>
| <syntax definition>
| (begin <command or definition>+)
| <conditional expansion form>
<conditional expansion form>
--> (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
The cond-expand 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-expand expands into the body of the first clause whose
feature requirement is currently satisfied (the else clause, 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-expand form, and FALSE otherwise. A feature requirement is
satisfied if its formula is true under this interpretation.
Examples:
(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-line is 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.