[Next] [Previous] [Up] [Top] [Contents] [Index]

4 Program Control

Conditional Execution

There are a number of statements and special operators that can be used to conditionally execute code. These are described in detail in Chapter 14, "The Built-In Macros and Special Operators."
Conditional Execution
Macro DescriptionPage
if Executes an implicit body if the value of a test is true or an alternate if the test is false.381
unless Executes an implicit body unless the value of a test is true.383
case Executes a number of tests until one is true, and then executes an implicit body associated with the true test.383
select Compares a target object to a series of potential matches, and executes an implicit body associated with the first match found.384
| Returns the value of the first of two operands which is true.Returns the value of the first of two operands which is true. This is a logical or operation.397
& Executes a second operand and returns its values if the value of the first operand is true. This is a logical and operation.398

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 special operator ~ is used for logical negation. If its operand is true, it returns #f. If its operand is #f, it returns #t.


Dylan Reference Manual - 17 OCT 1995
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker