[plt-scheme] Re: Problem with define-syntax. It is still not clear.
Andre Mayers wrote:
> Hello
>
> If you try the following code, it seems that the macro sees the list (1
> 3) in both case but fails to match. In both case x should be the list (1
> 3) and not (quote (1 3)). I don't understand why. I guess the answer is
> simple but I can't find it after a few hours.
>
> Thank you
>
> (define-syntax testListe
> (syntax-rules ()
> [(_ (1 3)) #t]
> [(_ xxx)
> (begin
> (display xxx)
> (newline)
> #f)]))
>
>
> (let ((x (list 1 3)))
> (testListe x))
Perhaps the pattern matching facility for run-time values is better
suited for your needs?
(require (lib "match.ss"))
(define (testListe ls)
(match ls
[(1 3) #t]))
(let ((x (list 1 3)))
(testListe x))
=> #t
HTH,
David