[plt-scheme] Null syntax / Conditional definition
On Saturday, June 18, 2005, at 01:17 PM, Mike wrote:
>> |(define-syntax (OS-dep stx)
>> | (syntax-case stx ()
>> | [(_ u w m)
>> | (case (system-type)
>> | [(unix) #'u]
>> | [(windows) #'w]
>> | [(macosx) #'m])]))
>
> What's the meaning of '_' in the expression after syntax-case?
Shorthand for "name of the macro", as I read it. In the case above
you'd have
(OS-dep (define foo 1) (define foo 2) (define foo 3))
for example, so
_ binds to OS-dep
u binds to (define foo 1)
w binds to (define foo 2)
and
m binds to (define foo 3)
There's nothing magical about "_" AFAIK; you could just as easily put
some other identifier there, and it should work. Consider:
(define-syntax (foo x) (syntax-case x () ((bar x) #'(cons 'bar 'x))))
jmj
--
Find out just what any people will quietly submit to, and you have the
exact measure of the injustice and wrong which will be imposed on them.
-- Frederick Douglass