HP Pascal/iX Reference Manual (31502-90022)

4-: 9
The compiler can be directed to perform or not perform partial evaluation
of Boolean operators used in statements. For example:
IF right_time AND right_place THEN ...
By specifying the $PARTIAL_EVAL ON$ compiler directive, if right_time is
false
, the remaining operators are not evaluated since execution of the
statement depends on the logical AND of both operators. Both operators
have to be
true
for the logical AND of the operators to be
true
.
Similarly, the logical OR of two operators are
true
even if only one of
the operators is
true
. Partial evaluation allows expressions like (Ptr
<> NIL) AND (Ptr^.F1) to execute without an error when Ptr is NIL.
Example
IF NOT possible THEN forget_it;
WHILE time AND money DO your_thing;
REPEAT...UNTIL tired OR bored;
IF has_rope THEN skip;
IF pain <= heartache THEN try_it;
FUNCTION NAND (A, B : BOOLEAN) : BOOLEAN;
BEGIN
NAND := NOT(A AND B); { NOT AND }
END;
FUNCTION XOR (A, B : BOOLEAN) : BOOLEAN;
BEGIN
XOR := NOT(A AND B) AND (A OR B); { EXCLUSIVE OR }
END;
FUNCTION XOR (A, B : BOOLEAN) : BOOLEAN;
BEGIN
XOR := A <> B;
END;
AND
This Boolean operator is used to perform the logical operation on two
Boolean operands. The result is of type Boolean. The following truth
table illustrates the operator AND along with its results.
OPERATOR RESULT
AND The evaluation of two Boolean operands produces a
Boolean result, such that:
(logical and)
----------------------------------------
| | | |
| a | b | a AND b |
| | | |
----------------------------------------
| | | |
| false | false | false |
| | | |
| false | true | false |
| | | |
| true | false | false |
| | | |
| true | true | true |
| | | |
----------------------------------------