[Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance (original) (raw)
Dave Anderson python3000 at davious.org
Thu Dec 7 16:37:24 CET 2006
- Previous message: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance
- Next message: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
on 12/7/2006 10:06 AM Hasan Diwan wrote:
The parametrized version of the pass keyword could be used to indicate a formal interface.
I may be missing something here, but we already have a mechanism for defining that a object defines certain methods. Could we not keep it orthogonal and have, e. g.: class super(): def init(self): pass def typeOfSuper(self): pass(subclass) The way pass is defined now would remain the default. A new builtin pass() would be added to support your notion of interfaces.
I feel on a different page from you.
My best guess it is that
def typeOfSuper(self): pass(subclass)
is ceding its implementation to its subclasses, kind of like what an abstract class or interface would do
but I feel my guess is wrong. Please clarify.
def addkeyvaluepair(arg: MutableContainer.add, key, value): arg[key] = value def add(self, onemore): MutableContainer.add (self, onemore.key, onemore.value):
I'm not getting the insight you are trying to convey by contrasting these two functions.
The former is an example of someone writing a function whose first parameter is expected to be any object that is derived from MutableContainer (including dict), or is derived from a class that implements MutableContainer (including those implementing dict), or is derived from a class that specifically implements MutableContainer.add using a declaration like:
class CanAdd: implements MutableContainer.add
def add(self, key, value):
...
The later seems to be a class method which uses MutableContainer's add method to add any object that has a key and a value attribute.
- Previous message: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance
- Next message: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]