Ah yes, okay that makes much more sense when put in the context of sets.

Thanks Darren

- Stevan

On Apr 29, 2009, at 7:02 PM, Darren Duncan wrote:

Stevan Little wrote:
On Apr 29, 2009, at 5:00 PM, Zbigniew Lukasiak wrote:
2. Every type is a subtype of itself
I don't understand that statement, can you please expand on it? Sounds kinda like my favorite "Class is an instance of Class" statement that "ties the knot" in the object system.

Here's an illustration that might clear it up: Saying "Int is a subtype of Int" is the same as saying "the set of all integers is a subset of the set of all integers".

If you conceive that a type is a set of values, then the terminology "subtype" and "supertype" and "union type" are merely terms you use when comparing two types to each other.

That is, if B is a subtype of A, then B consists of a subset of the values of A; this also means that A is a supertype of B. So given that any set is a subset or a superset of itself, any type has itself as a supertype or a subtype.

Now if you want to be exclusive, then you add the word "proper", so eg if you say that "B is a proper subtype of A" then A has at least one value that B doesn't, and also you can never say that a type is a proper subtype of itself.

Similarly, if the C is a union type over A and B, then C has all of and just the values that either A or B has; this also means that A and B are each subtypes of C. For example, Int is a union type over EvenInt and OddInt.

These terms, in the data model, are irrespective of declaration order or implementation details.

But they can be muddied when implemented since often the terms "subtype" and "union type" pull double duty to describe how a type is defined in the language in terms of others, but they still have the set-based meanings.

-- Darren Duncan

Reply via email to