[plt-scheme] Identifier macro assignment: syntax-id-rules vs. syntax-case

From: Casey Klein (clklein at calpoly.edu)
Date: Thu Jan 11 09:06:13 EST 2007

I tried naively to translate the language manual's `pwd' macro
(section 12.1) from the syntax-id-rules form to syntax-case:

   (define-syntax (pwd stx)
     (syntax-case stx (set!)
       [(set! pwd expr) #'(current-directory expr)]
       [(pwd expr ...) #'((current-directory) expr ...)]
       [pwd #'(current-directory)]))

Rather than expanding according to the first case, the expression 
(set! pwd "/tmp") tries to mutate the `pwd' binding. Why doesn't this
happen when the macro's defined with syntax-id-rules?


Posted on the users mailing list.