# E2-46: potential error?

From: Sandy Gao <sandygao@ca.ibm.com>
Date: Mon, 12 May 2003 11:31:12 -0400

```

1. given ·value space· A and ·value space· B where A and B are disjoint,
every pair of values a from A and b from B, a != b
2. two values which are members of the ·value space· of the same
·primitive· datatype may always be compared with each other
3. if a datatype T' is ·derived· by ·restriction· from a datatype T then
the ·value space· of T' is a subset of the ·value space· of T. Values in
the ·value space·s of T and T' can be compared according to the above rules
4. if datatypes T' and T'' are ·derived· by ·restriction· from a common
ancestor T then the ·value space·s of T' and T'' may overlap. Values in the
·value space·s of T' and T'' can be compared according to the above rules
5. if a datatype T is ·derived· by ·union· from ·memberTypes· A, B, ...
then the ·value space· of T is the union of ·value space·s of its
·memberTypes· A, B, .... Some values in the ·value space· of T are also
values in the ·value space· of A. Other values in the ·value space· of T
will be values in the ·value space· of B and so on. Values in the ·value
space· of T which are also in the ·value space· of A can be compared with
other values in the ·value space· of A according to the above rules.
Similarly for values of type T and B and all the other ·memberTypes·.

But in 3 & 4, if T is a union type, then the conclusion doesn't hold. For
example, if T is union of decimal and string, and T' and T'' both restrict
T without specifying any facets, then string("abc") and decimal(1) aren't
comparable (if both are from T', or one from T' and one from T''). So
either we remove 3 & 4 (their intention is implied by 1 & 2, so is 5's), or
limit T to atomic types in 3 & 4.

Thanks,
Sandy Gao