Reputation: 69
I am trying to create a recursive macro in a custom Racket language.
However, while the macro expands properly with #lang racket
, it fails when implemented with my new language.
For example, here is the recursive definition of a simple macro f
which expands to its last argument:
;; my-lang.rkt
#lang racket
(provide #%datum
#%module-begin
define-syntax
(for-syntax syntax-case
syntax
raise-syntax-error
#%app
quote
#%datum))
#lang s-exp "my-lang.rkt"
(define-syntax (f stx)
(syntax-case stx ()
[(_ x) #'x]
[(_ x xs ...) #'(f xs ...)]
[_ (raise-syntax-error 'f "bad syntax" stx)]))
(f 1 2 3) ; => f: bad syntax in: (f 2 3)
Why isn't (f 2 3)
matched and expanded?
Upvotes: 2
Views: 135
Reputation: 31147
Add ...
to the provided identifiers.
#lang racket
(provide #%datum
#%module-begin
define-syntax
(for-syntax syntax-case
syntax
raise-syntax-error
#%app
quote
quote-syntax
...
#%datum))
Upvotes: 1