[PEP draft 2] Adding new math operators

Konrad Hinsen hinsen at cnrs-orleans.fr
Wed Aug 9 14:17:03 EDT 2000


Gregory Lielens <gregory.lielens at fft.be> writes:

> Don't you fear the "backtracking" aspect, i.e. to have to track back the
> code to check the types of A and B, before knowing the operation which
> is perfromed by A 'op' B? 

In my experience, each type of object is used in a very specific part
of the code. The risk of confusion doesn't seem large then. No larger
at least than in other comparable situations, such as the string
addition you mention. It's a general feature of OO methods that the
precise definition of an operation depends on the types of the
operands. I don't hear people complaining about this, so I suppose it
works fine in most situations.

> However, when making the 'op' behavior differ for two very close classes
> (as array and matrix would obviously be), I think it could be a lot more
> error-prone...Similar (worst?) to the classical "1/2 == 0 (oops - why

Not necessarily. I already use similar close pairs (arrays plus some
higher-level problem-oriented array-like object) in many applications,
and I have never lost track of what is what.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------



More information about the Python-list mailing list