Contents | Prev | Next | Index


Relational Operators

= equal
# unequal
<> unequal
< less
<= less or equal
> greater
>= greater or equal
IN set membership
IS type test

Relations yield a BOOLEAN result. The relations =, #, <>, <, <=, >, and >= apply to operands of basic types, of enumerations, and of subranges. Relations = and # also apply to operands of set types, of pointer types, and (if the language extensions are enabled via a compiler switch or directive) also of procedure types (including the value NIL). x IN s stands for "x is an element of s". x must be of a value of the set base type of s, and s of a set type. v IS T stands for "the dynamic type of v is T (or an extension of T)" and is called a type test. It is applicable only if

  1. v is a variable parameter of record type or v is a pointer to record, and if
  2. T is an extension of the static type of v, and if
  3. the language extensions are enabled via a compiler switch or directive.

The following are examples of expressions (refer to examples in the section about variable declarations):

1991 INTEGER
i DIV 3 INTEGER
~p OR q BOOLEAN
(i+j)*(i-j) INTEGER
s-{8,9,13} BITSET
i+x REAL
a[i+j]*a[i-j] REAL
(0<=i) & (i<100) BOOLEAN
t^.key = 0 BOOLEAN
k IN {i..j-1} BOOLEAN
w[i].name <= "John" BOOLEAN
t IS CenterTree BOOLEAN

 


Contents | Prev | Next | Index

Canterbury Modula-2 for Java  (Last documentation update Feb 8, 2000)
Copyright © 1998 Mill Hill & Canterbury Corporation, Ltd. All rights reserved
Please send any comments or corrections to mhc@webcom.com