The following bindings are exported by the library (vicare
language-extensions cond-expand).
Expand to the definition of a syntax like cond-expand supporting
all the features of the cond-expand from SRFI-0 and in
addition supporting the features specified by a set of functions.
Features supported by Vicare
?cond-expand must be an identifier representing the name of the new syntax.
The optional ?feature-func arguments must be expressions which,
evaluated only once at expand time, must return functions; each of such
functions must accept as single argument an identifier representing a
feature and must return as single argument: #t if the feature is
supported, #f otherwise.
In the following example we define a cond-expand syntax just like
the one exported by SRFI-0:
#!r6rs (import (rnrs) (vicare language-extensions cond-expand)) (define-cond-expand cond-expand) (cond-expand ((and srfi-0 srfi-1) #t) (else #f)) → #t
in the following example we define a cond-expand that
additionally recognises the features write and display:
#!r6rs
(import (rnrs)
(vicare language-extensions cond-expand))
(define-cond-expand cond-expand
(lambda (id)
(free-identifier=? id #'display))
(lambda (id)
(free-identifier=? id #'write)))
(cond-expand
((or display write) #t)
(else #f))
→ #t
The following bindings are exported by the library (vicare
language-extensions cond-expand helpers).
Expand to the definition of a function bound to ?who which can be
used as feature function in uses of the macro define-cond-expand.
Each of the optional ?feature-clause must have the following format:
(?feature-id ?expr)
where ?feature-id must be the feature identifier and ?expr
must be an expression. The generated function compares the given
identifier with each of ?feature-id, using
free-identifier=?:
#t: evaluate ?expr and return the result.
#f: move on to the next ?feature-id.
#f.
In the following example we define a cond-expand that
additionally recognises the features write and display:
#!r6rs
(import (rnrs)
(vicare language-extensions cond-expand)
(for (vicare language-extensions cond-expand)
expand))
(define-cond-expand cond-expand
(let ()
(define-cond-expand-identifiers-helper help
(display #t)
(write #t))
help))
(cond-expand
((or display write) #t)
(else #f))
→ #t