[Python-3000] Adaptation vs. Generic Functions

Terry Reedy tjreedy at udel.edu
Wed Apr 5 08:30:58 CEST 2006


"Guido van Rossum" <guido at python.org> wrote in message 
news:ca471dc20604041729s227336bdp41c122700886380c at mail.gmail.com...
> #!/usr/bin/python2.4
>
> """An example of generic functions vs. adaptation.

Nice.

For me, the idea of 'generic function' goes into my brain much more 
smoothly than the idea of 'protocol adaptation' even though the effect 
seems to be about the same.  That is because I think of Python as a 
language for writing generic algorithms.  Untyped polymorphic expressions, 
coupled with special methods that plug user types into the syntax of such 
expressions, are the main means to do so.  But when these are inadequate 
(because different types require different expressions, or because some 
types benefit from specialized expressions) or difficult (due to 
builtin-ness or inavailability of code), a more generic means might be a 
nice addition.

One test of whether a specific implementation of the idea should be added 
is whether it would be used to replace some of the ad hoc special-case 
methods, as with pickle reduce.

Terry Jan Reedy





More information about the Python-3000 mailing list