Compatibility with both Chez and Chicken Scheme

323 Views Asked by At

I'm trying to write a program compatible with both Chez and Chicken Scheme. Starting with something maximally simple:

(c1) R:\>type  hello.ss
(display "hello, world\n")

(c1) R:\>csc hello.ss

(c1) R:\>hello
hello, world

(c1) R:\>"C:\Program Files\Chez Scheme 9.5.8\bin\a6nt\scheme.exe" --program hello.ss
Exception: invalid top-level program import subform (display "hello, world\n") at line 1, char 1 of hello.ss

Chicken is happy with the simplest version, but Chez isn't. Okay, I know a way to make Chez happy:

(c1) R:\>type  hello2.ss
(import (rnrs))
(display "hello, world\n")

(c1) R:\>"C:\Program Files\Chez Scheme 9.5.8\bin\a6nt\scheme.exe" --program hello2.ss
hello, world

But does Chicken like that version?

(c1) R:\>csc hello2.ss

Syntax error (import): cannot import from undefined module

        rnrs

        Expansion history:

        <syntax>          (##core#begin (import (rnrs)))
        <syntax>          (import (rnrs))       <--

Error: shell command terminated with non-zero exit status 70: ""c:/chicken/bin/chicken.exe" "hello2.ss" -output-file "hello2.c""

Sadly, no.

How can I write a program that both implementations are happy with?

0

There are 0 best solutions below