[plt-scheme] About matching ors...

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Fri Feb 17 18:35:18 EST 2006

Paulo J. Matos wrote:
> Hi,
> 
> When requiring plt-match.ss and trying:
> (define test
>     (match-lambda
>       [(list (or id
>                  (list x y z)))
>        (printf "~a ~a ~a ~a ~n" id x  y z)]
>       [_
>        (printf "buh~n")]))
> 
> I get:
> expand: unbound variable in module in: x
> 
> Why x? Why not id?
> This is a curious situation because probably some variables might
> become unbound, right? I couldn't find a place on the manual
> describing in detail this issues but it's wierd.

   * (or pat1 ··· patn) -- matches if any of the subpatterns match.
   At least one subpattern must be present.

   All subpatterns must bind the same set of pattern variables.

It's the last requirement that you pattern violates - but the
error message isn't too clear.

-- 
Jens Axel Søgaard




Posted on the users mailing list.