[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Scheme-reports] Top-level cond-expand for backwards compatibility
- To: scheme-reports@x
- Subject: [Scheme-reports] Top-level cond-expand for backwards compatibility
- From: Christian Stigen Larsen <csl@x>
- Date: Sun, 9 Jun 2013 22:40:04 +0200
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 v22.214.171.124
$ 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*?
If not, I think we've made a small blunder with regards to backwards
Christian Stigen Larsen
Scheme-reports mailing list