[plt-scheme] sytnax macro question

From: John W. Small (jsmall at atlantech.net)
Date: Sun May 11 15:21:34 EDT 2003

The following syntax macro appears to work okay (or at least
as expected).

 >  (define-syntax test
     (lambda (stx)
       (syntax-case (list (- 2 1) (+ 1 1) (+ 2 1)) ()
         ((x y ...)
           (begin
             (display (syntax-object->datum
               (syntax (x y ...))))
             (newline)
             (syntax (list x y ...)))))))
 >  (test)
 (1 2 3)     ; output displayed
 (1 2 3)     ; returned value

If the (begin ...)  expression is unwrapped the following works
only if two expressions occurs in the clause of the case.

>  (define-syntax test
     (lambda (stx)
       (syntax-case (list (- 2 1) (+ 1 1) (+ 2 1)) ()
         ((x y ...)
             (display (syntax-object->datum
               (syntax (x y ...))))
  ;           (newline)
             (syntax (list x y ...))))))
 > (test)
 (1 2 3)     ; output displayed
 (1 2 3)     ; returned value

However if the (newline) is uncommented leaving 3 statements in the case
clause the following error occurs.

    syntax-case*: bad clause in: ((x y ...) (display (syntax-object->datum (syntax (x y ...)))) (newline) (syntax (list x y ...)))

Is this correct behavior?  or is the case clause broken?  I noticed that SISC
complains in the exact same manner making me thing I have a fundamental misunderstanding.

Note: the purpose this macro is simply to investigate the behavior of expansion time
execution of the code related to syntax-case.


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

Posted on the users mailing list.