[plt-scheme] Null syntax / Conditional definition
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"))
> (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 "???")))))))
: Jordan Johnson - jorjohns @ cs . indiana . edu
: If I were a bug, I would want to be a true Renaissance bug.