cond-expand

Is (cond-expand ...) supported at the REPL?

cond-expand was originally defined in SRFI 0. It was included in R7RS with an additional (library ...) requirement type. Notably, cond-expand is absent from R6RS and all prior RnRS standards, though many implementations of those standards support it.

Supported: Gauche, MIT, Chicken, Bigloo, Kawa, SISC, STklos, SigScheme, Scheme 9, RScheme, S7, SXM, Foment, Chibi, Sagittarius, Guile

Not supported: Racket* , Scheme48/scsh, SCM, Chez, Vicare*, Larceny*, Ypsilon*, Mosh, IronScheme, NexJ, JScheme, KSi, Shoe, TinyScheme, BDC, XLisp, Rep, Schemik, Elk, Llava, Sizzle, FemtoLisp, Dfsch, Inlab, Owl Lisp

*Said to support SRFI 0 through a third-party library; not tested

Note: Although SRFI 0 says that cond-expand can only be portably used at the top level, all the above Schemes support nested cond-expand. R7RS allows cond-expand anywhere a syntactic expression is permitted (it's also a library declaration).

Can it skip unknown requirement types?

SRFI 0 specifies only the following types of requirements:

R7RS adds:

If cond-expand stops evaluating and as soon as a requirement fails to match, then a symbol can be used as a guard for each new requirement type, and it's possible to write future-proof things like this:

(cond-expand
  ((and no-such-feature (no-such-test arg))
   'impossible)
  (else
   'expected))

Which implementations support the above?

Signal an error:


Back to Scheme Surveys

Page source (GitHub)