[Python-Dev] type categories

Andrew Koenig ark@research.att.com
24 Aug 2002 11:53:44 -0400


Guido> For example, if we ever are going to add argument type declarations to
Guido> Python, it will probably look like this:

Guido>     def foo(a: classA, b: classB):
Guido>         ...body...

Guido> It would be convenient if this could be *defined* as

Guido>     assert isinstance(a, classA) and isinstance(b, classB)

Guido> so that programs that have a simple class hierarchy can use their
Guido> classes directly as argument types, without having to go through the
Guido> trouble of declaring a parallel set of interfaces.

Guido> I also think that it should be possible to come up with a set of
Guido> standard "abstract" classes representing concepts like number,
Guido> sequence, etc., in which the standard built-in types are nicely
Guido> embedded.

I agree completely.  Any use of inheritance that satisfies Liskov
substitutability will satisfy interface inheritance too, and although
it is possible to think of uses of inheritance that arent substutitable,
they're unusual enough that they should probably require (syntactic)
special pleading, if only to alert the reader.

-- 
Andrew Koenig, ark@research.att.com, http://www.research.att.com/info/ark