chickadee » scheme » base » cond-expand

(cond-expand <ce-clause1> <ce-clause2> ...)syntax

The cond-expand expression type provides a way to statically expand different expressions depending on the implementation. A <ce-clause> takes the following form:

(<feature requirement> <expression> ...)

The last clause can be an "else clause," which has the form

(else <expression> ...) ]

A ⟨feature requirement⟩ takes one of the following forms:

<feature identifier>

(library <library name>)

(and <feature requirement> ...)

(or <feature requirement> ...)

(not <feature requirement>)

Each implementation maintains a list of feature identifiers which are present, as well as a list of libraries which can be imported. The value of a <feature requirement> is determined by replacing each <feature identifier> and (library <library name>) on the implementation’s lists with #t, and all other feature identifiers and library names with #f, then evaluating the resulting expression as a Scheme boolean expression under the normal interpretation of and, or, and not.

A cond-expand is then expanded by evaluating the <feature requirement>s of successive <ce-clause>s in order until one of them returns #t. When a true clause is found, the corresponding <expression>s are expanded to a begin, and the remaining clauses are ignored.

If none of the <feature requirement>s evaluate to #t, then if there is an else clause, its <expression>s are included. Otherwise, the behavior of the cond-expand is unspecified. Unlike cond, cond-expand does not depend on the value of any variables.

The following features are built-in and always available by default: chicken, srfi-0, srfi-2, srfi-6, srfi-8, srfi-9, srfi-11, srfi-12, srfi-15, srfi-16, srfi-17, srfi-23, srfi-26, srfi-28, srfi-30, srfi-31, srfi-39, srfi-46, srfi-55, srfi-61, srfi-62, srfi-87, srfi-88.

There are also situation-specific feature identifiers: compiling during compilation, csi when running in the interpreter, and compiler-extension when running within the compiler.

The symbols returned by the following procedures from (chicken platform) are also available as feature-identifiers in all situations: (machine-byte-order), (machine-type), (software-type), (software-version). For example, the machine-type class of feature-identifiers include arm, alpha, mips, etc.

Platform endianness is indicated by the little-endian and big-endian features.

In addition the following feature-identifiers may exist: cross-chicken, dload, gchooks, ptables, case-insensitive.