Unable to redefine imported symbols in r7rs library
Issue #266
wontfix
I found this while playing with some code from chibi. The simplified code is like this
(define-library (abc)
(import (scheme base) (srfi 1))
(export everyx)
(begin
(define (every) #f)
(define everyx every)))
and it fails to build
$ ./build/sagittarius -r7 -L . -e '(import (abc))'
Unhandled exception
Condition components:
1. &compile
program: (import (abc))
source: #f
2. &compile
program: (define-library (abc) (import (scheme base) (srfi 1)) (expor
source: "/home/pclouds/W/sagittarius-scheme/abc.scm":1
3. &syntax
subform: (every)
form: (define (every) #f)
4. &message attempt to modify immutable variable
5. &stack-trace
because “every” is already defined in (srfi 1) and I attempt to redefine it.
I have not read r7rs-small again, but I don’t think redefining symbols is forbidden. At least it used to work like that in r5rs. It’s not a competition, but as far I can test, Gauche, Chibi and Larceny all accept this code.
Comments (3)
-
repo owner -
repo owner - changed status to wontfix
-
reporter Thanks for clarification!
- Log in to comment
Thanks for the report!
It is an error to redefine the imported variables according to the R7RS section 5.2. Which means, raising an error is perfectly fine. As you mention, it’s not a competition, I don’t change the current behaviour since Sagittarius is one of the R6RS/R7RS implementations.
NOTE: this must signal an error on R6RS.