[Python-3000] Kill "generic functions"!

Guido van Rossum guido at python.org
Thu Apr 6 22:33:46 CEST 2006


On 4/6/06, Phillip J. Eby <pje at telecommunity.com> wrote:
> The issue is more that Java programmers think they need to use
> staticmethod because that sounds to them like a Java "static method",
> instead of doing something more appropriate like a classmethod or a
> module-level function.  I worry that "overloading" will make them
> think it should be used the way it's used in Java, where it often
> substitutes for Java's lack of default arguments.  Not only that, but
> overloading in Java means you have to write different implementations
> for different types, even in cases where duck typing would be more
> appropriate.  It's especially confusing given Java's mix of
> object-based and non-object numeric types.  ISTM that C++ has even
> worse connotations for this.

But at least C++ has default argument values.

I don't believe that Java programmers using Python will attempt to
write multiple overloaded versions of a method for different types
that have the same API (duck typing). If they do, they have more
serious problems.

> So, when I say that "overload" has the wrong connotations, I'm not
> talking about some abstract understanding of what it is or does, I'm
> talking about the wrong connotations for their practical intuition of
> how the thing should be *used*.  The use cases for overloading in the
> languages that have it are way different, and if you move those
> concepts over to generic functions without a critical
> reinterpretation of the concept, you will write atrocious Python that
> will be hard to read and perform badly.

I think that the solution to this would be a book or course "Python
for Java programmers". Not using the most natural name for a feature
because Java programmers might misunderstand it sound like the wrong
motivation.

Plus, the syntax for using overloaded functions/methods is
sufficiently verbose that the elegance of using default argument
values is hard to miss.

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


More information about the Python-3000 mailing list