let (x1 l1) (x2 l2) ⋯ (xn ln) l |
switch l with case c1: l1 ⋯ case ck: lk default: d |
default: d
can be omitted. In such a
case the switch behavior is unspecified on non-recognized values.
Scheme C can thus omit the default clause when it is known that
case lists will cover all possibilities at runtime.
We use the keyword switch* to highlight switch
constructs with no default clause.x = (x1 x2… xn), P → L = |
|
match x with | p1 -> e1 | p2 -> e2 … | pm -> em |
catch
C((x), (
|
C((), |
|
) = l1 |
P' → L' = |
|
) |
p1i | S(c,P → L) | ||||||||
c(q1i, … , qai) | q1i | ⋯ | qai | p2i | ⋯ | pni | → | li | |
c'(q1i, … , qa'i) (c' ≠ c) | No row |
(let (y1 (field 0 x1)) ... (ya (field (a−1) x1)) C((y1, … ,ya,x2, … ,xn),S(c,P → L))) |
switch x1 with case c1: r(c1) ⋯ case ck: r(ck) default: exit |
P = |
|
, |
C((x1), |
|
); C( (x2… xn), ( p2…pn → l )) |
catch C(x, P1 → L1) with C(x, P2 → L2) |