[plt-scheme] Null syntax / Conditional definition

From: Chihiro Kuraya (rxqvw at yahoo.co.jp)
Date: Sat Jun 18 11:58:29 EDT 2005

Hi,
Thank you for answer.

Jordan Johnson <jorjohns at cs.indiana.edu> wrote:
> On Saturday, June 18, 2005, at 05:39  AM, Chihiro Kuraya wrote:
> > (1) Is it possible to define syntax or syntax-id
> > which disappears when expanded ?
> 
> To answer your first question:
> 
> (define-syntax my-append
>    (syntax-rules ()
>      ((_ s1 (discard s2))
>       (string-append s1 s2))
>      ((_ s1 discard s2)
>       (string-append s1 s2))))
> 
> (my-append "pqr" ABC "xyz")
> (my-append "pqr" (ABC "xyz"))

What I want to do is defining ABC macro
which is not specific to string-append.

For example, I want also (list 123 ABC 456)
to be expanded to (list 123 456).


> > (2) Is it possible to switch syntax definition (or normal definition)
> > depending on some flags?
> 
> For your example, here's what comes to mind (though there's probably a 
> better way):
> 
> (define ABC
>    (case (system-type)
>      ((windows) 123)
>      ((macosx) 567)
>      (else #f)))
> 
> (define-syntax XYZ
>    (case (system-type)
>      ((windows)
>       (lambda (x)
>         (syntax-case x ()
>           ((_ arg0 ...)
>            #'(display "Win")))))
>      ((macosx)
>       (lambda (x)
>         (syntax-case x ()
>           ((_ arg0 ...)
>            #'(display "Mac")))))
>      (else
>       (lambda (x)
>         (syntax-case x ()
>           ((_ arg0 ...)
>            #'(display "???")))))))

I expect all definitions not intended for Windows
are stripped after syntax expansion.
The above code doesn't suffice my expectation.
Is it possible ?


Chihiro Kuraya
__________________________________
Save the earth
http://pr.mail.yahoo.co.jp/ondanka/



Posted on the users mailing list.