Syntax: cond-expand cond-expand-clause* [(else command-or-definition*)]
cond-expand-clause::=(feature-requirementcommand-or-definition*)
feature-requirement::=feature-identifier
|(andfeature-requirement*)
|(orfeature-requirement*)
|(notfeature-requirement)
|(librarylibrary-name)
feature-identifier::=a symbol which is the name or alias of a SRFI
The
cond-expandform 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; theelseclause, if present, is selected if none of the previous clauses is selected.The implementation has a set of feature identifiers which are “present”, as well as a set of libraries which can be imported. The value of a
feature-requirementis determined by replacing eachfeature-identifierby#tif it is present (and#fotherwise); replacing(librarybylibrary-name)#tiflibrary-nameis importable (and#fotherwise); and then evaluating the resulting expression as a Scheme boolean expression under the normal interpretation ofand,or, andnot.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-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.You can use
java-6,java-7,java-8, orjava-9to check if the underlying Java is a specific version or newer. For example the namejava-7matches for either Java 7, Java 8, or newer, as reported bySystemproperty"java.version".You can use
class-exists:to check ifClassNameexists at compile-time. The identifierClassNameclass-exists:org.example.MyClassis roughly equivalent to the test(library (org example MyClass)). (The latter has some special handling for(srfi ...)as well as builtin Kawa classes.)
Returns a list of feature identifiers which
cond-expandtreats as true. This not a complete list - for exampleclass-exists:feature identifiers are not included. It is an error to modify this list. Here is an example of whatClassNamefeaturesmight return:(features) ⇒ (complex exact-complex full-unicode java-7 java-6 kawa ratios srfi-0 srfi-4 srfi-6 srfi-8 srfi-9 srfi-11 srfi-16 srfi-17 srfi-23 srfi-25 srfi-26 srfi-28 srfi-30 srfi-39 string-normalize-unicode threads)
Syntax: include-relative path+
These take one or more path names expressed as string literals, find corresponding files, read the contents of the files in the specified order as if by repeated applications of
read, and effectively replace theincludewith abeginform containing what was read from the files.You can control the search path used for
includeby setting thekawa.include.pathproperty. For example:$ kawa -Dkawa.include.path="|:/opt/kawa-includes"The special
"|"path element means to search relative to the directory containing the including source file. The default search path is"|:."which means to first search the directory containing the including source file, and then search the directory specified by(current-path).The search path for
include-relativeprepends"|"before the search path used byinclude, so it always searches first the directory containing the including source file. Note that if the default search path is used thenincludeandinclude-relativeare equivalent; there is only a difference if thekawa.include.pathproperty changes the default.Using
include-ciis likeinclude, except that it reads each file as if it began with the#!fold-casedirective.