[Python-3000] Abilities / Interfaces

Bill Janssen janssen at parc.com
Wed Nov 22 04:53:29 CET 2006


> Bill Janssen seems to be in favor of just using ABCs. Pro: less new
> infrastructure. Con: hard to add a new ABC on the fly to an existing
> 3rd party class (mucking with __bases__ is too much of a hack to
> seriously propose).

Don't get me wrong, I think having optional interface-based method
dispatch would be an additional goodness, if only for the
documentation aspect of it.  But yes, I think adding ABC to define the
interfaces, and using inheritance for aggregation, is the way to go
about it.  I think an additional benefit would be an increased
emphasis on mixins as a simple way to add functionality.  About that
con -- perhaps a new bit of machinery could be added to muck with
__bases__ in a principled fashion?  But isn't this a bit like the
argument about anonymous code blocks?  If someone wants to add a new
ABC to an existing third-party class, can't they just write

  class NewClass(ExistingThirdParty, NewABC):
    pass

and use an instance of that new class?  Then we get into the argument
about factories that only produce instances of ExistingThirdParty, and
so on...

> 2. Do we need interfaces if we have generic functions?

I don't mind having both, but generic functions (interface-based
method dispatch) is really only one aspect of the issue.

Bill


More information about the Python-3000 mailing list