Next: Symbols, Previous: Miscellaneous Datatypes, Up: Miscellaneous Datatypes

The boolean objects are true and false. The boolean
constant true is written as ``#t`', and the boolean constant false is
written as ``#f`'.

The primary use for boolean objects is in the conditional expressions
`if`

, `cond`

, `and`

, and `or`

; the behavior of these
expressions is determined by whether objects are true or false. These
expressions count only `#f`

as false. They count everything else,
including `#t`

, pairs, symbols, numbers, strings, vectors, and
procedures as true (but see True and False).

Programmers accustomed to other dialects of Lisp should note that Scheme
distinguishes `#f`

and the empty list from the symbol `nil`

.
Similarly, `#t`

is distinguished from the symbol `t`

. In
fact, the boolean objects (and the empty list) are not symbols at all.

Boolean constants evaluate to themselves, so you don't need to quote them.

#t => #t #f => #f '#f => #f t error--> Unbound variable

— variable: **false**

— variable:**true**

— variable:

These variables are bound to the objects

`#f`

and`#t`

respectively. The compiler, given the`usual-integrations`

declaration, replaces references to these variables with their respective values.Note that the symbol

`true`

is not equivalent to`#t`

, and the symbol`false`

is not equivalent to`#f`

.

— procedure: **boolean?**` object`

Returns

`#t`

ifobjectis either`#t`

or`#f`

; otherwise returns`#f`

.(boolean? #f) => #t (boolean? 0) => #f

— procedure: **not**` object`

— procedure:**false?**` object`

— procedure:

These procedures return

`#t`

ifobjectis false; otherwise they return`#f`

. In other words theyinvertboolean values. These two procedures have identical semantics; their names are different to give different connotations to the test.(not #t) => #f (not 3) => #f (not (list 3)) => #f (not #f) => #t

— procedure: **boolean=?**` obj1 obj2`

This predicate is true iff

obj1andobj2are either both true or both false.