[Python-3000] Interfaces (was: Re: Adaptation vs. Generic Functions)

Ian Bicking ianb at colorstudy.com
Wed Apr 5 22:23:11 CEST 2006


Guido van Rossum wrote:
> Fascinating ideas in this thread!

It's certainly been interesting to see convergence coming from both 
directions independently.

> I spent some time blogging about this on artima:
> http://www.artima.com/weblogs/viewpost.jsp?thread=155123
> 
> I have to write my slides for a talk about Py3K later today, but I'll
> be back. In the mean time I've rejected PEPs 245 and 246 in
> expectation of something better that's imminent!

Is PEP 245 ("Python Interface Syntax") that related to adaptation or 
generic functions?  Certainly they've gone hand-in-hand for some time, 
but adaptation as an idea isn't really going away (just rephrased), and 
the motivation for the formalism of an interface isn't going away 
either.  So I don't think this invalidates the interface PEP.

Maybe a more minimal PEP is called for.  Or one revised with 
consideration of Zope interfaces; though that implementation mixes 
interfaces and adaptation in a way that the original PEP does not.

Potentially the whole thing could just be a module in the standard 
library; the only real language support called for at all is an 
"interface IFoo:" special form.  The PEP also gives a form "class Foo 
implements IBar:", but that doesn't seem needed or in line with the way 
decorators work; class decorators would resolve this issue (+1 on 
"@class decorator" in the class body).

For documentation alone I would find interfaces very useful, and I write 
ad hoc (non-Zope) interfaces from time to time for that reason.  But 
there's no tool support then.  OTOH, I'd be non-plused if interfaces and 
interface-related assertions popped up all over the place; I really only 
like them when using objects between library boundaries.  Anyway, it 
seems like interfaces deserve their own discussion.

-- 
Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org


More information about the Python-3000 mailing list