[Python-3000] Adaptation vs. Generic Functions

"Martin v. Löwis" martin at v.loewis.de
Thu Apr 13 15:40:22 CEST 2006


> Guido writes:
>> the conventional way of treating __add__
>> etc. has a different need for resolving conflicts than Phillip Eby's
>> idea of requiring strict dominance of the selected solution over all
>> other candidates. So now that you mention it I wonder if the whole
>> strict dominance requirement isn't a red herring? And perhaps we
>> should in general use "returns NotImplemented" as a signal to try the
>> next best candidate, strict dominance be damned...

Michael Chermside wrote:
>      my_x = my_mpz + my_array
> 
> THIS then raises an exception because there is no one dominant
> definition.

Or, to make a long story short: there might not be a single next
best candidate, but multiple, which are mutually equally-good:
both mpz+object and object+array would match, and neither is
better than the other.

This is because they only form a partial order. Of course, it
might be possible to impose a total order on top of it (e.g.
giving the left-more operands higher precedence, or considering
the order of registration). This all sound arbitrary, though.

Regards,
Martin


More information about the Python-3000 mailing list