When this matters
Choose a conditional by the shape of the question: one yes/no test, several predicates, one value compared with fixed datums, or a side effect that should run only in one case. Remember that only #f is false.
See it run
LISPEX
(case 2 ((1) 'one) ((2) 'two) (else 'other))Observed result
OUTPUT
twoRead the example
case evaluates 2 once, compares it with each listed datum using eqv?, and selects the second clause. The quoted symbol two is the result; the else clause is not evaluated.
How to reason about it
cond,case,and,or,when,unless,let*, namedlet,do, and quasiquote preserve pinned evaluation and tail positions.- Generated temporaries and hidden intrinsics cannot be captured or shadowed by user names.
casecompares datums witheqv?;whenandunlessfalse paths produce zero values.
Choose quickly
| Form | Use it when | Result behavior |
|---|---|---|
if | there are exactly two branches | returns the selected branch |
cond | different predicates name several cases | returns the first matching clause |
case | one value is compared with fixed datums | evaluates the key once |
and / or | tests form a short-circuit chain | returns an operand value, not a coerced boolean |
when / unless | a one-sided effect is clearer | false path returns zero values |
A common mistake
There is no define-syntax or user macro expansion.
Current boundaries
- Bare
unquoteandunquote-splicingoutside quasiquote are static errors.
Keep going
The data-and-decisions lesson teaches the everyday forms. Derived Forms gives their exact normalization shapes.