[plt-scheme] another macro+module anomaly

From: Benderjg2 at aol.com (Benderjg2 at aol.com)
Date: Tue Nov 26 23:06:45 EST 2002

I have run into another strange interaction between a macro and module, where 
my macro behaves differently when defined outside a module versus inside a 

As an example, I give the following small module and macro definition:

(module ex mzscheme
  (provide test)
  (define-syntax (test stx)
    (syntax-case stx (-)
      ((_ (- a b))
       (syntax '(subtract a b)))
      ((_ (op a b))
       (syntax '(op a b)))))

When I test this macro (at the top level),
 (test (+ 3 4))   ==> (+ 3 4)   ;; this is "correct"
 (test (- 3 4))    ==> (- 3 4)    ;; this is wrong!

This is a silly macro, but the example with "-" yields the wrong result!
But when I define this macro at the top-level, outside of a module, I get the 
correct result:
 (test (- 3 4))    ==> (subtract 3 4)

Other symptoms:
- if I change the "-" in this macro to "diff", (test (diff 3 4)) ==> 
(subtract 3 4)
  (other names bound in to values, such as * and + also fail to work in this 
- names (presumably) bound to syntax, such as "or" work fine


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20021126/d7ed4d02/attachment.html>

Posted on the users mailing list.