Chapter 4
Program Control
Conditional Execution
There are a number of statements and function macros that can be used to conditionally
execute code. These are described in detail
in Chapter 14, The Built-In Macros and
Special Definitions.
Macro / Operator |
Description |
Page |
---|---|---|
|
Executes an implicit body if the value of a test is true or an alternate if the test is false. |
|
|
Executes an implicit body unless the value of a test is true. |
|
|
||
|
||
|
Returns the value of the first of two operands that is true. This is a logical or operation. |
|
|
If the value of a first operand is true, executes a second operand and returns its values. This is a logical and operation. |
True and False
For the purposes of conditional execution, there is a single object that counts as false, and all other objects count as true.
The false object is the constant #f
. There is
a canonical true object, #t
, which can be used for clarity of
code. #t
and #f
are instances of the
class <boolean>
.
Because all values besides #f
count as true, the term true or false
is
not equivalent to
.#t
or #f
The operator ~
is used for logical negation. If its operand
is true, it returns #f
. If its operand is #f
, it
returns #t
.