Author paul.moore
Recipients doerwalter, ncoghlan, paul.moore, ryan.freckleton
Date 2009-02-05.11:59:34
SpamBayes Score 1.68415e-06
Marked as misclassified No
Message-id <1233835177.48.0.886593944329.issue5135@psf.upfronthosting.co.za>
In-reply-to
Content
Agreed (in principle). However, in practice the subtleties of override
order must be documented (and a method of implementation must be
established!!!) Consider:

>>> class A:
...     pass
...
>>> class C:
...     __metaclass__ = abc.ABCMeta
...
>>> class D:
...     __metaclass__ = abc.ABCMeta
...
>>> C.register(A)
>>> D.register(A)
>>> @generic
... def pprint(obj):
...     print "Base", str(obj)
...
>>> @pprint.register(C)
... def pprint_C(obj):
...     print "Charlie", obj
...
>>> @pprint.register(D)
... def pprint_D(obj):
...     print "Delta", obj
...
>>> pprint(A())

What should be printed? A() is a C and a D, but which takes precedence?
There is no concept of a MRO for ABCs, so how would the "correct" answer
be defined? "Neither" may not be perfect, but at least it's clearly
defined. Relying on order of registration for overloads of the generic
function seems to me to be unacceptable, before anyone suggests it, as
it introduces a dependency on what order code is imported.

So while the theory makes sense, the practice is not so clear.
Respecting ABCs seems to me to contradict the "simple" aspect of
simplegeneric, so a documented limitation is appropriate. 

(But given the above, I'm more inclined now to leave the name as
"simplegeneric", precisely to make this point :-))
History
Date User Action Args
2009-02-05 11:59:37paul.mooresetrecipients: + paul.moore, doerwalter, ncoghlan, ryan.freckleton
2009-02-05 11:59:37paul.mooresetmessageid: <1233835177.48.0.886593944329.issue5135@psf.upfronthosting.co.za>
2009-02-05 11:59:36paul.moorelinkissue5135 messages
2009-02-05 11:59:34paul.moorecreate