[plt-scheme] syntax-parse literals

From: Jon Rafkind (rafkind at cs.utah.edu)
Date: Mon Oct 19 14:13:28 EDT 2009

The set of literals that can be used in syntax-parse have to be defined 
which quickly leads me to a situation where I have duplicate 
identifiers. Is there some way to tell syntax-parse an identifier is a 
literal without defining it? In general it seems like a bad idea to have 
to define all literals as it pollutes the namespace.

This code gives a duplicate identifier for 'a' and 'b'.

(define (test2)
  (define-syntax mymacro
    (syntax-rules ()
      [(_ (literal ...)
          (name pattern ...)
         (define-syntax literal (lambda (stx) (error 'literal "dont use 
this"))) ...
         (define-syntax (name stx)
           (syntax-parse stx
                         #:literals (literal ...)
                         [(_ pattern ...) #'template])))]))
  (mymacro (a b) (foo a b) 1)
  (mymacro (a b) (bar a b) 2)
  (foo a b))

Posted on the users mailing list.