type
1
"a"
Warning: t happens to be both a boolean and a symbol, so be careful when mixing symbols with booleans.
t
t
2
"b"
Warning: nil happens to be a boolean, a list, and a symbol, so be careful when mixing lists with booleans, symbols with booleans, or lists with symbols.
t
t
t
t
t
nil
nil
syntax
( if question-exprthen-exprelse-expr)
1
2
It evaluates the two branches lazily, meaning it doesn’t evaluate then-expr unless the question really is t , and it doesn’t evaluate else-expr unless the question really is nil . So this division-by-zero expression never gets evaluated.
"the-other-thing"
"the-first-thing"
This makes if (and similar forms like cond ) useful for guarding function calls against bad data.
:output-contractt;this division is only evaluated when y isn't 0> (try-/26)1/3
> (try-/20)nil
This delay in evaluating the branches is also important for functions that use recursion, so it doesn’t evaluate the recursive call when it should be on the base case.
2
3
Like if , cond evaluates its answer expressions lazily, which means it can be used to guard against bad data, or to guard recursive calls.
"the-other-thing"
"the-first-thing"
:output-contractt;this division is only evaluated when y isn't 0> (try-/36)1/2
> (try-/30)nil
syntax
( and conjunct-expr...)
t
nil
nil
nil
t
nil
Like if and cond , and evaluates its arguments lazily, only when all of the previous arguments have praduced t . So this division by zero expression never gets evaluated:
nil
syntax
( or disjunct-expr...)
t
t
t
nil
nil
t
Like if and cond , or evaluates its arguments lazily, only when none of the previous arguments have praduced t . So this division by zero expression never gets evaluated:
t
nil
t
syntax
( implies ante-exprconseq-expr)