[previous] [up] [next]     [contents] [index]
Next: When and Unless Up: Conditionals Previous: Conditionals

Cond and Case

In MzScheme's normal mode,[footnote] the result of a cond expression with no matching clause is void (see section 4.1). In other modes, evaulating a non-matching cond raises the exn:else exception.

Every case expression is expanded into a cond expression; depending on the MzScheme's running mode, evaluating a case expression with no matching clause will raise the exn:else exception.

An else clause in a cond or case expression must be the last clause, otherwise a syntax error is signalled. If => is used in the second position within a cond clause and it is not followed by a single recipient expression, a syntax error is signalled.

The else and => identifiers in a cond or case statement are handled specially only when they are not lexically bound:

  (cond ([1 => add1])) ; => 2
  (let ([=> 5]) (cond ([1 => add1]))) ; => #<primitive:add1> 


PLT