[plt-scheme] define-syntax in define-syntax

From: Jos Koot (jos.koot at tiscali.nl)
Date: Tue Sep 7 19:02:27 EDT 2004

I still use version 103p and have a macro that defines syntaxes by means of define-syntax. It works fine. As a simplified example:

(define-macro syntax-maker
 (lambda (name . clauses)
 `(define-syntax ,name
   (syntax-rules ()
   , at clauses
   ((,name x ...) ; catch all other patterns
    (list 'error "in syntactic form:" '(,name 'x ...)))))))
(syntax-maker monkey ((monkey x y ...) '("monkey" x y ...)))
(monkey 1 2 3) --> ("monkey" 1 2 3)
(monkey) --> (error "in syntactic form:" (monkey))

This cannot be rewritten as:

(define-syntax syntax-maker
 (syntax-rules ()
  ((syntax-maker name (pattern template) ...)
   (define-syntax name
    (syntax-rules ()
     (pattern template) ...
      ((name x ...); catch all other patterns ; <=== wrong
       (list 'error "in syntactic form:" '(,name 'x ...))) <=== wrong
(syntax-maker monkey ((monkey x ...) (list "monkey" 'x ...)))
(monkey 1 2 3) --> raises an error-exception, of course

This is wrong because the outer define-syntax form wants to spline the syntactic variable 'x' in the marked lines. Is there a work-around (other than using define-macro for the outer form)? Id est, how can I insert an ellipsis in the inner define-syntax form without the outer one noticing it? Or is there a reason why I should not want it?

Thanks in advance.
Jacob Koot.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20040908/a8ce095e/attachment.html>

Posted on the users mailing list.