[plt-scheme] re: another macro+module anomaly

From: Benderjg2 at aol.com (Benderjg2 at aol.com)
Date: Sun Apr 6 21:46:21 EDT 2003

Several months ago I posted a query regarding matching literals in macros, 
for which the answer was to use syntax-case* with 
'module-or-top-identifier=?'. For my problem at the time, this solved the 

But a curious point for me, was that I had a problem symbols which were, also 
bound MzScheme _values_. 'or' and 'and' seemed to work just fine. I think, 
mistakenly, I concluded that this was a problem for value bindings, but not 
syntactic bindings. I say this because, while 'or' and 'and' work just fine, 
with-or-without the use of 'module-or-top-identifier=?', "class" fails even 
with the use of 'module-or-top-identifier=?'. Now I am just confused ;)

The module:

(module ex mzscheme
  (provide test)
  (require-for-syntax (lib "stx.ss" "syntax"))
  (define-syntax (test stx)
    (syntax-case* stx (- or class) module-or-top-identifier=?
      ((_ (- a b))
       (syntax '(subtract a b)))
      ((_ (class a b))
       (syntax '(matched a b)))
      ((_ (or a b))
       (syntax '(intersection a b)))
      ((_ (op a b))
       (syntax '(op a b)))))

This follows the early proposed solution, and hence,
  (test (or 1 5)) ==> (intersection 1 5)
And, of course, the original "problem"
  (test (- 1 5))
produces "(subtract 1 5)" as intended.

But curiously, 
  (test '(class 1 5))
produces "(class 1 5)"
rather than the (intended--for this silly test) "(matched 1 5)".

As a work around, I am simply coercing the syntax object into a datum, and 
testing whether this eq?'s 'class. But is there a better way to deal with 

I have tested this with both v202 and v203, with the same results.


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

Posted on the users mailing list.