Re: apparent bug in sample implementation of SRFI 148
Takashi Kato 20 Jul 2017 06:48 UTC
> Now it is a mystery to me why I got different results from Chibi and
> Sagittarius when I tried the example yesterday.
Sagittarius has 2 implementation of syntax-rules, one is for (rnrs base)
and the other one is for (scheme base). If you start REPL without -r7
command line option, then it imports (rnrs) to the REPL environment.
And if you do pass the -r7 option, then it imports (scheme base).
OK, now suppose we have the following 2 files:
;; syn-match-r6.scm
(import (rnrs))
(define-syntax foo
(syntax-rules ()
((foo bar x)
(define-syntax bar
(syntax-rules (x)
((bar c) 'matched)
((bar z) 'unmatched))))))
(foo bar c)
(display (bar q)) (newline)
;; syn-match-r7.scm
(import (scheme base) (scheme write))
(define-syntax foo
(syntax-rules ()
((foo bar x)
(define-syntax bar
(syntax-rules (x)
((bar c) 'matched)
((bar z) 'unmatched))))))
(foo bar c)
(display (bar q)) (newline)
Both are identical except the import clauses. And the following is the
result of execution
$ sash -r6 syn-match-r6.scm
matched
$ sash -r7 syn-match-r7.scm
unmatched
The R6RS version of syntax-rules returns matched the same as other R6RS
implementations (Tested on Chez and Racket's plt-r6rs).
The R7RS version returns unmatched and Chibi also returned the same
on my environment. (NB: The R7RS version is based on Chibi's syntax-rules,
so it's not surprising to me)
Interestingly, Gauche with -r7 option returned matched. So not all R7RS
implementations agreed to return unmatched.
Cheers,
--
_/_/
Takashi Kato
E-mail: ktakashi19@gmail.com