[Types-sig] A type checking system in Python
Marcin 'Qrczak' Kowalczyk
qrczak@knm.org.pl
24 Mar 2001 19:32:06 GMT
Wed, 21 Mar 2001 05:09:13 -0500 (EST), Clark C. Evans <cce@clarkevans.com=
> pisze:
> From: Huaiyu Zhu <hzhu@mars.localdomain>
>=20
> Type checking system in Python
>=20
> Classes implement a hierarchy of inheritance of attributes (variables a=
nd
> methods). They are useful for implementation modularization.
>=20
> There is another type of modularization that is similar in nature, but =
is
> independent of classes. This is the hierarchy of polymorphic interface=
s.
[...]
I like it. It's consistent with my view being clarified in discussions
here, that interfaces are objects which provide definitions of checking
whether an object conforms to them.
An aspect which is missing here, and I think it's important, is that
some objects need wrapping to support particular interfaces. It can
be expressed in various ways:
- retrieving functions from the interface instead of the object
(there is more than one choice for passing the object(s) whose interfac=
e
is checked),
- let the interface return an adaptor for a given object (this is
single-dispatch-centric).
Since an interface specifies arbitrary requirements about an object,
some interfaces may specify that objects have method with particular
names. This seems to be necessary for interfaces like Integer, where
retrieving definitions from any other place than objects themselves
would not allow the handy syntax of x+y, and builtin types luckily
provide these methods.
But in general an interface can be a source of methods in addition
to mere checking. It will construct these methods for objects which
don't have them themselves, and is multiple-dispatch-friendly.
--=20
__("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZAST=CAPCZA
QRCZAK