Explicit versus implicit subtyping mechanisms (was: polymorphism and dynamically typed languages)

Explicit versus implicit subtyping mechanisms (was: polymorphism and dynamically typed languages)

Post by Alfredo No » Wed, 11 May 2005 20:53:28


On Tue, 10 May 2005 11:11:11 +0100, Miguel Oliveira e Silva



Good question.


It seems a circular definition.


I don't think that it is excellent.

I prefer the standard definition:

A type is a set of values and a set of associated operations wich act
on that values.

http://www.yqcomputer.com/
http://www.yqcomputer.com/
http://www.yqcomputer.com/

http://www.yqcomputer.com/

BTW "type", "data type" and "abstract data type" are exactly the same.

I find "abstract data type" unnecessarily redundant because it would
not make any sense to talk about "non abstract data types".


The question is: what is a class?

Class is many times a synonym of type.


Class sometimes means that, but we should not mix theory with
implementation.


I don't see sense here.


On types conforming types?

BTW I don't know any commercial programming language which implements
subtyping. OO inheritance has nothing to do with subtyping.

When we code this in Java:

if (circle is Ellipse)

We are not checking whether the value contained in the circle variable
is an Ellipse, we are cheching whether the type of the circle variable
was created using the type Ellipse as a basis.

Here "is" does not mean "is". That's why in OO a circle usually "is"
not an ellipse.

Quoting Bill Clinton:

It depends on what the meaning of the word 'is' is

:)

The funniest thing is that OO inheritance is not incompatible with
subtyping.

We could implement the type Ellipse extending the type Circle and we
could declare the type Circle as a subtype of Ellipse at the same
time.

The we could do something like this.

if (circle is Ellipse)
OK();
else
Impossible();

(here' is' means 'is')

if (Ellipse extends Circle)
WhyNot?();


Regards