[Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance
janssen at parc.com
Thu Dec 7 17:25:26 CET 2006
> To me, even if Car happens to represent a dict by being able to be used
> as a dict, the expression of this fact feels better expressed as merely
> implementing dict.
> class Car(dict): # car... is a dict? hmm, a bad ring to it
> class Car:
> implements dict # oh, Cars can be used like a dict, got it
OK, I guess the difference is that, for me, (1) this doesn't happen a
lot (ever?), and (2) I don't feel that the nuance here is important
enough to add another mechanism to the language which needs to be
supported. I'd rather just use type inheritance.
> Without something like an implements declaration, if I ever
> want to express a relationship to another class, but with different
> internals, I am forced to first define an abstract class and then
> inherit from that. With an implements declaration, I can say implements
> dict and be free of inheriting any of its internal implementation.
That's why it's important for Python to have a clear set of base
interface types for people to use.
> In the syntax sketch, an Implementation is basically a list of
> types/class, methods, and other Implementation lists.
That sounds a whole lot like a Python 2.5 class, to me.
More information about the Python-3000