Modula-3: Relations

# Relations

         infix    =, #  (x, y: Any): BOOLEAN

The operator `=` returns `TRUE` if `x` and `y` are equal. The operator `#` returns `TRUE` if `x` and `y` are not equal. It is a static error if the type of `x` is not assignable to the type of `y` or vice versa.

Ordinals are equal if they have the same value. Floats are equal if the underlying implementation defines them to be; for example, on an IEEE implementation, `+0` equals `-0` and `NaN` does not equal itself. References are equal if they address the same location. Procedures are equal if they agree as closures; that is, if they refer to the same procedure body and environment. Sets are equal if they have the same elements. Arrays are equal if they have the same length and corresponding elements are equal. Records are equal if they have the same fields and corresponding fields are equal.

         infix    <=, >=  (x,y: Ordinal) : BOOLEAN
                          (x,y: Float)   : BOOLEAN
                          (x,y: ADDRESS) : BOOLEAN
                          (x,y: Set)     : BOOLEAN

In the first three cases, `<=` returns `TRUE` if `x` is at most as large as `y`. In the last case, `<=` returns `TRUE` if every element of `x` is an element of `y`. In all cases, it is a static error if the type of `x` is not assignable to the type of `y`, or vice versa. The expression `x >= y` is equivalent to `y <= x`.

         infix    >, <    (x,y: Ordinal) : BOOLEAN
                          (x,y: Float)   : BOOLEAN
                          (x,y: ADDRESS) : BOOLEAN
                          (x,y: Set)     : BOOLEAN

In all cases, `x < y` means `(x <= y) AND (x # y)`, and `x > y` means `y < x`. It is a static error if the type of `x` is not assignable to the type of `y`, or vice versa.

Warning: with IEEE floating-point, `x <= y` is not the same as `NOT x > y`.

         infix    IN (e: Ordinal; s: Set): BOOLEAN

Returns `TRUE` if `e` is an element of the set `s`. It is a static error if the type of `e` is not assignable to the element type of `s`. If the value of `e` is not a member of the element type, no error occurs, but `IN` returns `FALSE`.

    Last modified on Wed Apr  3 09:38:58 PST 1996 by heydon
         modified on Mon Apr 18 14:06:39 PDT 1994 by kalsow