Up Next
Go up to Expressions
Go forward to Relational Expressions

Logical Expressions

< expression > -> < logical term >
| < expression > | < logical term >
< logical term > -> < logical factor >
| < logical term > & < logical factor >
< logical factor > -> < relational expression >
| ! <relational expression>

JACCL provides the logical `and' ( & ), `or' ( | ) and `not' ( ! ) operators. In JACCL, these operators are actually applied to integers. They interpret their operands using the usual scheme: 0 represents `false' and any non-zero value represents `true'. The logical and relational operators of JACCL all produce the value 1 when the result of an operation is `true'.

The ! operator has the highest precedence among the logical operators followed by & and finally |. Operators of equal precedence are grouped from left to right.

The & and | operators are evaluated lazily in JACCL. That is, if the first operand of an & operator is zero, a result of zero is returned without ever evaluating the second operand. Similarly, if the first operand of an | operator is non-zero, the second operand will not be evaluated.


Computer Science 434
Department of Computer Science
Williams College

Up Next