[Python-3000] Special methods and interface-based type system
Guido van Rossum
guido at python.org
Thu Nov 23 00:54:28 CET 2006
On 11/22/06, Bill Janssen <janssen at parc.com> wrote:
> 2) But also, if Python was built with interfaces, "special" methods
> would each be in their own namespace. That is, a user wouldn't have
> to worry about accidentally overriding a method; they'd have to
> explicitly override the "len" method inherited from the "container"
> interface; just defining a method called "len" in their subclass
> wouldn't do it. CLOS is rather elegant in this respect.
Ow, that's the first time you describe this particular wrinkle. I
don't know anything by CLOS. Python has a rather much simpler approach
to attribute namespaces for class instances; you can have only one
attribute named "len" (since it's contained within a class, most folks
consider this sufficient localization to not have to worry about
conflicts). I don't think that anyone else here thought of ABCs or
interfaces introducing separate namespaces yet. The __special__
namespace is effectively a second namespace, orthogonal to the regular
namespace, because there's an explicit convention that you shouldn't
define __special__ attributes unless you are implementing whatever
semantics a particular __special__ name has.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000