I've used the following cond-expand trick to write R7RS programs that are
backwards compatible with RnRS implementations that support SRFI-0:
(import (scheme base)
(display "Hello, world")
This works out-of-the-box on a lot of implementations:
$ chibi-scheme cond-expand.scm # v0.6.1
$ csi -bq cond-expand.scm # chicken v126.96.36.199
$ mit-scheme --batch-mode < cond-expand.scm # v15.3
$ guile cond-expand.scm # v1.8.8
$ scheme cond-expand.scm # tinyscheme 1.39
$ bigloo -i cond-expand.scm # v3.8c
I could not get this to work with Scheme48 or Larceny and didn't attempt it
on other implementations.
It also does not work with Mickey Scheme, because I can't figure out if I
should allow it or not.
The problem is that I believe this form of usage is strictly not valid R7RS,
at least not according to the EBNF in R7RS, ch. 7.1.6 (draft 9):
<command or definition>+
As such, (import ...) must come before any commands and cond-expand is
defined in (scheme base) --- I'm ignoring the second definition of
cond-expand inside (import ...) blocks.
I know the document allows implementations to extend the language, given it
does not conflict with R7RS. But there's a difference between a language
and its implementation.
So, is the code above valid in the R7RS *language*?
_______________________________________________ Scheme-reports mailing list Scheme-reports@x http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports