Comment on PEP-0238

Robert J. Harrison rjh at 3-cities.com
Mon Jul 2 09:54:21 EDT 2001


Paul Prescod <paulp at ActiveState.com> wrote in message news:<mailman.994016102.30019.python-list at python.org>...
> ... Python guesses based on
> the types of the operands which is a poor choice in a dynamically typed
> language that otherwise treats "5.0" as a more verbose alternate syntax
> for "5"
> ...
> If Python were to always disallow integer/float coercion then users
> would learn that and life would go on. Instead, it coerces in some
> places and not others.

The current coercion rules are simple, easy to grasp, and consistent
with how most people are taught arithmetic.
The PEP proposes even simpler rules, but in the process of doing so
discards much of the ease of using integers as integers.

The problems I have with the proposal are

  1) It adds no new capability or expressivity and breaks a very 
     large amount of code.  The __future__ mechanism is no cure for this. 

  2) Integers should be treated as a distinct type from reals with
     automatic coercion only as necessary (with the current rules).
     For instance, the new proposal sensibly does not suggest that lists
     should support real indices, however simple expressions such
     as a[i/3] would have to be coded as a[int(i/3)] or a[i//3]
     in order to be sure to avoid a type error.

Robert



More information about the Python-list mailing list