- (match-let [var] ((pat exp) …) body …)syntax
- (match-let* ((pat exp) …) body …)syntax
- (match-letrec ((pat exp) …) body …)syntax
The match-let, match-let* and match-letrec forms generalize Scheme's let, let*, letrec, and define expressions to allow patterns in the binding position rather than just variables. For example, the following expression:
(match-let (((x y z) (list 1 2 3))) ((a b c) (list 4 5 6))) body …)
binds x to 1, y to 2, z to 3, a to 4, b to 5, and c to 6 in body …. These forms are convenient for destructuring the result of a function that returns multiple values as a list or vector. As usual for letrec, pattern variables bound by match-letrec should not be used in computing the bound value.
Analogously to named let, match-let accepts an optional loop variable var before the binding list, turning match-let into a general looping construct.