PEP0238 lament

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Jul 24 09:57:36 EDT 2001


Tue, 24 Jul 2001 14:33:47 +0100, Steve Horne <sh at ttsoftware.co.uk> pisze:

>>> Language design mistake.
>>
>>It allows to write code which increments a number of unknown type
>>by one. How would you write it in your universe?

> Literals can be used for any type where the representation matches,
> so incrementing is not a problem.

Ok, this applies to Ada and Haskell. But how to fix the "design
mistake" in Python?

IMHO it doesn't have a practical fix, as long as a literal is an
expression with type independent from the context. This implies that
implicit conversions from int to float and rational are unavoidable
in Python. Without them some reasonable code is hard to write.

So we must continue to design the meaning of operators under the
assumption that mixed-type arithmetic promotes arguments to some
common type.

Letting int/int return a rational and unifying int with long (or
unifying int and long with rationals, but I don't propose this) are
the last missing steps to be able to give 5 when a rational or float
is expected, and to give 1/16 where a float is expected, without
getting incorrect results. Now it almost works: as long as there
is no overflow, the only problem is division.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list