Conditionals and Derived Forms

A small core of `if`, sequencing, binding, lambda, application, assignment, and quotation receives hygienically normalized derived forms.

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
two

Read 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*, named let, do, and quasiquote preserve pinned evaluation and tail positions.
  • Generated temporaries and hidden intrinsics cannot be captured or shadowed by user names.
  • case compares datums with eqv?; when and unless false paths produce zero values.

Choose quickly

FormUse it whenResult behavior
ifthere are exactly two branchesreturns the selected branch
conddifferent predicates name several casesreturns the first matching clause
caseone value is compared with fixed datumsevaluates the key once
and / ortests form a short-circuit chainreturns an operand value, not a coerced boolean
when / unlessa one-sided effect is clearerfalse path returns zero values

A common mistake

There is no define-syntax or user macro expansion.

Current boundaries

  • Bare unquote and unquote-splicing outside quasiquote are static errors.

Keep going

The data-and-decisions lesson teaches the everyday forms. Derived Forms gives their exact normalization shapes.

Data and decisions · Derived Forms