[plt-scheme] syntax error with match-lambda**

From: Madoka Machitani (madokama at gmail.com)
Date: Thu Mar 11 01:11:04 EST 2010


I'm using PLT Scheme ver. 4.2.4, and I see the following error message
when using match-lambda**:

car: expects argument of type <pair>; given #<syntax (((T R a x b) y
(T R c z d)) ...>

It seems to use plain car instead of stx-car against the syntax object.

After fixing this, however, I've encountered some other syntax errors.


match*: expected a sequence of patterns in: syntax

I think this is due to the inecessary syntax-quotes around the pattern
variables here:

 [body #`(match*/derived #'vars #,stx #'(clauses ...))]

After removing these, I saw the third (and final) error like this:

match: wrong number of match clauses, expected 3 and got 2 in: (((T R
a x b) y (T R c z d)) (T R (T B a x b) y (T B c z d)))

The pattern shown in the error looks a bit over-parenthesized, so I dropped
the parentheses around "clauses ..." off.

So, to show you the fixes in entirety:

     (define-syntax (match-lambda** stx)
       (syntax-parse stx
         [(_ (~and clauses [(pats ...) . rhs]) ...)
          (with-syntax* ([vars
			   (car (syntax-e #'((pats ...) ...))))]
			 [body #`(match*/derived vars #,stx clauses ...)])
            (syntax/loc stx (lambda vars body)))]))

It certainly works as before.  I hope it helps.


Posted on the users mailing list.