Jarnac includes the usual range of relational operators. One special point to make is that the equivalence
operator is the `==’ symbol.
For example, to test whether the variable a equals the value four we would use:
if a == 4 then ....
The reason why the `==’ symbol was chosen rather than say the more obvious use of `=’, is that the
interpreter is unable to distinguish in an expression such as a = 4 whether you mean an assignment or an
equivalence test. In languages such as Pascal, the assignment operator is `:=’ so that equivalence can be
tested using `=’. Jaranc follows the same notation as in other languages such as C, Java or Python which
also use `==’ to indicate an equivalence test.
Jarnac also includes the built-in boolean constants, True and False.
Operation
`x and y' Boolean and
`x or y' Boolean or
'x xor y' Boolean xor
`not x' Boolean not
` ` `>' Greater than
`>=' Greater than or equal
`<>' No equal to
`==' Equality test
Examples:
Option1 = True; Option2 = False;
Choice = Option1 or Option2;
if Choice = True then .....
is equivalent to the shorter version:
if Choice then .....
The boolean operators, and, or, not, xor have a higher priority than relational operations such as <, >
etc. This means it is important when mixing these operations in a single expression, that the relational
tests are bracketed away from the boolean operator. For example:
if (5 > 1) and (5 < 10) then .....
is the correct way to write such an expression, where as `if 5 > 1 and 5 < 10 then..' will result in a
runtime error. The reason for this is that in the unbracketed version the term 1 and 5 will be computed
before the relational tests resulting in the intermediate expression, if 5 > False < 10 which clearly makes
no sense because it is not possible to test whether a boolean such as False is greater or less than an integer!