[Python-Dev] type categories

Alex Martelli aleax@aleax.it
Sat, 24 Aug 2002 17:37:36 +0200


On Saturday 24 August 2002 05:15 pm, Jeremy Hylton wrote:
> Good point, Oren.  We now have two requirements for interfaces that
> are different than the standard inheritance mechanism.  It should be
> possible to:
>
>   - inherit from a class without implementing that class's interfaces
>
>   - declare that a class implements an interface outside the class
>     statement
>
> It's harder to support the second requirement using the current
> inheritance mechanism.

The second requirement is a good part of what adaptation is meant
to do.  As I understand, that's exactly what Zope3 already provides
for its interfaces.  You don't just "declare" the fact -- you register
an adapter that can provide whatever is needed to make it so.  I.e.,
if object X does already implement interface Y without ANY need
for tweaking/renaming/whatever, I guess the registered adapter
can just return the object X it receives as an argument.  More often,
the adapter will return some (hopefully thin) wrapper over X that
deals with renaming, signature-adaptation, and the like.

That's how it works in Zope3 (at least as I understood from several
discussions with Jim Fulton and Guido -- haven't studied Zope3 yet), and I 
think that such "external adaptation" functionality, however dressed up, 
should definitely be a part of whatever Python ends up with.


Alex