[Python-3000] Generic functions vs. OO

Phillip J. Eby pje at telecommunity.com
Thu Nov 23 22:05:15 CET 2006


At 03:54 PM 11/23/2006 -0500, Phillip J. Eby wrote:
>5. Generic functions are easily grasped as a dynamic version of overloading
>as seen in other languages (including C#, Java, C++, etc., where there's no
>built-in notion of "adaptation")

Oh, and I forgot: they're also easily understood as generic or polymorphic 
functions by people who use them in languages like CLOS, Dylan, Haskell, 
etc.  Not that that's necessarily a big population compared to the above 
languages, but my point here is that even these less-popular languages 
don't really have adaptation as such.  (Haskell's typeclasses are also very 
close in spirit to the interface approach I propose, but that's neither an 
advantage nor disadvantage, just a data point.)

Also, COM and .NET *do* have a notion of interfaces, but it's actually more 
similar to what I'm proposing than to what Zope or PyProtocols interfaces 
do.  They are like typeclasses in the sense that an interface on a COM 
object is normally just a stateless adapter providing an effective "method 
namespace" on the object.

Anyway, the point was just that one advantage of my proposal is that it's 
easier to teach, because it has many things it can be compared to, 
depending on the audience: dynamic overloading, generic functions, 
typeclasses, COM "query-interface", etc.  It can even be compared to 
existing Python interface implementations, in terms of what things it can 
do that they can't, as well as the things they have in common.  :)



More information about the Python-3000 mailing list