Mike Krell wrote: > On 5/11/06, Guido van Rossum <[EMAIL PROTECTED]> 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 types that we are talking about are nothing more than duck types, so you are right about that part. What's different is what we want to be able to *do* with the types. A lot of modern programming languages get their power by being able to do reasoning with types. Virtual functions, generic functions, inheritance, multiple inheritance, polymorphism, and all these other aspects of typing can be thought of as a kind of "type calculus" - in other words, they are all a kind of mathematical function where one or more of the parameters is a type, and the result is different depending on what types you put into it. The basic push behind this thread is to be able to do a similar kind of type calculus on duck types. Naturally, since the duck types have a more ambiguous definition than explicit types, the resulting calculus will need to be able to handle ambiguity (at the very minimum, by reporting it as an error.) But "fuzzy logic" can be just as formal and well-defined as "crisp logic". -- Talin _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com