[Python-Dev] type categories

Martin v. Loewis martin@v.loewis.de
13 Aug 2002 22:27:29 +0200


Andrew Koenig <ark@research.att.com> writes:

> So what I wonder is this:  Has there been much thought about making
> these type categories more explicitly part of the type system?

Certainly. Such a feature has been called "interface" or "protocol"; I
usually associate with "interface" a static property (a type
implements an interface, by means of a declaration) and with
"protocol" a dynamic property (an object conforms to a protocol, by
acting according to the rules that the protocol set).

Your question exist in many variations. One of it lead to the creation
of the types-sig, another one triggered papers titled "Optional Static
Typing", see

http://www.python.org/~guido/static-typing/

The most recent version of an attempt to making interfaces part of
Python is PEP 245,

http://python.org/peps/pep-0245.html

I believe there is agreement by now that there will be difference
between declared interfaces and implemented protocols: an object may
follow the protocol even if it did not declare the interface, and an
object may violate a protocol even if its type did declare the
interface.

Beyond that, there is little agreement.

Regards,
Martin