[plt-scheme] Problem with define-syntax

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Thu Jan 19 00:30:53 EST 2006


On Wed, 18 Jan 2006, Andre Mayers wrote:

> I miss something which is surely basic.  How can I define a macro that
> will match a list ?  Why the following is not working ?
>
> (define-syntax testListe
>   (syntax-rules ()
>     [(_ (1 3)) #t]
>     [(_ xxx) #f]))
>
>
> (define x '(1 3))
> (testListe  x)


Hi Andre,

All that the macro knows about is syntactic stuff; when we do something
like:

    (testListe x)

then the pattern matcher only sees the symbol x: it doesn't look at the
runtime value of x.

Here's the one input to testListe that will return #t:

######
> (testListe (1 3))
#t
######


Hope this helps!



Posted on the users mailing list.