[Python-3000] my take on "typeclasses"

Guido van Rossum guido at python.org
Thu May 11 22:40:16 CEST 2006


On 5/11/06, Mike Krell <mbk.lists at gmail.com> wrote:
> On 5/11/06, Guido van Rossum <guido at python.org> wrote:
> > I think I'm more comfortable with a maximal taxonomy. In a maximal
> > taxonomy, I'd describe a large set of invariants, attributes,
> > behavior, etc., and say e.g. "this is how a file behaves". A
> > particular class can then claim to be a file by explicitly declaring
> > this (how that's spelled is a different issue -- it doesn't need to be
> > done by inheritance from an abstract base class or interface, it could
> > also be an arbitrary property, agreed upon by convention, or an
> > external registry of all file types, for example).
>
> If the route chosen is "agreed upon by convention" what is the
> difference between this and duck typing?  Are the "claim" and
> "convention" anything more than comments in the code?

The claim should be introspectable. *Conformance* to the claimed API
may be hard to introspect but IMO the claims should be introspectable,
separate from whatever we (think we) know about hasattr().

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list