[plt-scheme] About matching ors...

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Thu Feb 16 19:15:59 EST 2006

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.

Another question:
(define parse
    (match-lambda
        [(list (or 'x 'y 'z) a ...)
         <<<<<<<<<<<<<<<<< How can know which of the first elements
matched (x, y, or z)?
        )))

My solution is usually to drop the match-lambda, use match, add an
argument and then check the car of the argument to see which one
matched but is there a better way?

Cheers,
--
Paulo Jorge Matos - pocm at sat inesc-id pt
Web: http://sat.inesc-id.pt/~pocm
Computer and Software Engineering
INESC-ID - SAT Group


Posted on the users mailing list.