PEP0238 lament

Tim Peters tim.one at home.com
Sun Jul 22 17:45:02 EDT 2001


[James Logajan]
> This has probably already been brought up, but perhaps the problem lies
> not with the "/" operator, but one step earlier in distinguishing the
> meaning of:
>
> x = 3
> and
> x = 3.
>
> That is subtle difference that can cause quite different results later
> on.

Why is that?  It's because unlike any other builtin arithmetic operation,
"/" today can cause *catastrophic* loss of information silently, and in
ordinary cases.  If code sticks to + - * and **, it usually doesn't matter
much in the end whether someone says

    x = 3
or
    x = 3.

at the start.  But toss in one "/", and radically different results are
common.

> Or, one may try to teach that when ALL arguments of an operator are in
> one "set", such as the set of integers, then one must expect a result
> that is an element from THAT set, not another set, such as the set of
> real numbers or from the set of complex numbers.  Set theory seems to
> be taught fairly early on in math, I think.

I think you're missing that the proponents are arguing on pragmatic grounds:
this has mostly to do with that x/y surprises people in real life.  It's not
that there aren't clear rules, or that the rules can't be taught, or that
people are too stupid to understand the rules.  Guido hears all the
complaints, and he's become convinced that this is a genuine and serious
flaw in the language:  the current rules are *unusable* for too many people
too often.  If you're not one of them, congratulations <wink>.  I'm not
either -- I never get burned by this.  But I see plenty of people who are,
and they're neither stupid nor careless; it's a common blind spot, so it
doesn't really matter that it's not one I (or you) suffer.

> ...
> I prefer a handful of general rules, and operators that obey them.

Of course, but computer numerics is a massive exercise in picking the
general rules you want to preserve at the expense of others, and trading all
that off against pragmatics too.  Not losing information silently is also a
Very Good General Rule, and even 745 binary fp arithmetic is better at
meeting that one than current "/".





More information about the Python-list mailing list