shirok / Gauche

Scheme Scripting Engine
https://practical-scheme.net/gauche
Other
812 stars 81 forks source link

define-syntax does not accept identifiers injected with synrules #42

Closed okuoku closed 10 years ago

okuoku commented 10 years ago

Following defMyQuote syntax should define quote with specified name but Gauche's syntax-rules does not accept identifier which inserted with syntax-rules so we cannot define TEMP here.

R7RS define-syntax should accept any identifier not only symbols so I think R7RS requires support this.

(define-syntax defMyQuote
  (syntax-rules ()
    ((_ name)
     (begin
       (define-syntax TEMP
         (syntax-rules ()
           ((_ arg)
            `arg)))
       (define-syntax name
         (syntax-rules ()
           ((_ arg)
            (TEMP arg))))))))

(defMyQuote MyQuote)

(write (MyQuote symbol))(newline)
$ gosh m.scm
*** ERROR: Compile Error: symbol required, but got #<identifier user#TEMP>
"./m.scm":14:(defMyQuote MyQuote)

$ gosh -V
Gauche scheme shell, version 0.9.4 [utf-8,pthreads], i686-pc-cygwin
shirok commented 10 years ago

Fix is in 0f85b90

Note: The current implementation make TEMP visible in the module that calls defMyQuote. We may rename TEMP in future for better hygiene.