[Python-3000] Adaptation vs. Generic Functions

Paul Moore p.f.moore at gmail.com
Thu Apr 13 17:04:47 CEST 2006


On 4/13/06, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> 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.

While this is true, I'd argue that mpz+object is over-general. After
all, mpz+list is not expected to work, presumably, so the library
authors are promising more than they actually deliver.

The mpz library authors should have registered signatures for all
applicable types in the core and standard library (quite possibly only
int/long - I'm not sure that even mpz+float makes sense) and left all
other cases for people using mpz with non-standard types.

Of course, this exposes a potential usability issue - there may be a
reasonable number of cases where an "obvious" derivation works. But
there's no way of specifying this, so there's a temptation to specify
an over-general signature, like mpz+object.

Paul.


More information about the Python-3000 mailing list