cond-expand missing from the default R7RS environment
Hi and thank you for a very nice Scheme implementation!
Would it be possible to add cond-expand
to the sagittarius -r 7
default environment? Currently the following happens:
$ echo '(cond-expand (sagittarius 1))' >test.scm
$ sagittarius test.scm
$ sagittarius -r 7 test.scm
Unhandled exception
Condition components:
1. &undefined
2. &who sagittarius
3. &message unbound variable sagittarius in library user
4. &stack-trace
stack trace:
[1] #f
src: (sagittarius 1)
"test.scm":1
[2] eval
[3] main-loop
[4] dynamic-wind
[5] scriptvi
cond-expand can be imported from (scheme base)
but having it without (scheme base)
would be useful for compatibility with non-native-R7RS Scheme implementations like Chicken which require (import (r7rs))
before (import (scheme base))
.
Comments (8)
-
repo owner -
reporter Thank you. Gauche and Kawa also expose cond-expand by default so you will be in good company :)
gosh -r 7 -e '(cond-expand (gauche (write 1)))' -e '(exit)'
kawa --r7rs -e '(cond-expand (kawa 1))'
-
repo owner - changed status to resolved
Importing cond-expand on -r7 before the script execution (Fixes
#264)→ <<cset b6e102d2d5cc>>
-
repo owner Seems Gauche doesn't resolve
cond-expand
on R7RS mode$ scheme-env run gauche@0.9.7 -- -r7 ~/foo.scm *** ERROR: invalid syntax: (else #f) While compiling "/**/foo.scm" at line 1: (cond-expand (gauche (import (scheme base)) (display "ok") (newline)) (else #f)) While loading "/**/foo.scm" at line 4 Stack Trace: _______________________________________
;; foo.scm (cond-expand (gauche (import (scheme base)) (display "ok") (newline)) (else #f))
You may also want to create an issue on Gauche’s repository, then (might already been done though)
-
reporter Tested the fix but it doesn’t seem to take quoting into account:
$ echo "(cond-expand (sagittarius 123))" >hello.scm $ sagittarius hello.scm $ sagittarius -r 7 hello.scm Unhandled exception Condition components: 1. &undefined 2. &who sagittarius 3. &message unbound variable sagittarius in library user 4. &stack-trace stack trace: [1] #f src: (sagittarius 123) "hello.scm":1 [2] eval [3] main-loop [4] dynamic-wind [5] script
You’re right about Gauche, it seems to be stricter in R7RS script mode than R7RS REPL mode.
You need to also import
(scheme write)
to getdisplay
. But it still doesn’t work:(cond-expand (gauche (import (scheme base) (scheme write)) (display "ok") (newline)))
Gives the error:
$ gosh -r7 foo.scm ok *** ERROR: unbound variable: gauche While loading "./foo.scm" at line 1
-
repo owner The fix requires rebuilding sagittarius including precompiled files. Check the ‘Building from repository’ section of the repository home page.
-
reporter Chibi doesn’t work so easily either when running a file:
(cond-expand (chibi (import (scheme base) (scheme write)) (display "ok") (newline)))
Error:
$ chibi-scheme foo.scm ERROR on line 3 of file foo.scm: undefined variable: display
-
reporter Thanks! I rebuilt is according to your instructions and it works
$ cat >hello.scm (cond-expand (sagittarius (import (scheme write) (scheme base)) (display "ok") (newline))) $ sagittarius -r 7 hello.scm ok
- Log in to comment
Thank you for the report!
I've checked Chibi Scheme and it does resolve![:wink: 😉](https://pf-emoji-service--cdn.us-east-1.prod.public.atl-paas.net/standard/a51a7674-8d5d-4495-a2d2-a67c090f5c3b/48x48/1f609.png)
cond-expand
without importing(scheme base)
. I’ll accept the proposal