proposed language change to int/int==float (was: PEP0238 lament)
Tim Peters
tim.one at home.com
Mon Jul 30 02:05:19 EDT 2001
[Guido van Rossum]
> ...
> On the other hand, floats should never be usable as sequence index.
> Scheme defines this quite nicely:
>
> http://www.swiss.ai.mit.edu/ftpdir/scheme-reports/r5rs-html/r5rs_8
.html#SEC50
>
Except that Scheme has nothing against reals being used as sequence indices:
exactness is orthogonal to numeric type in Scheme, and being usable as a
sequence index relies on exactness.
> (real? 3)
#t
> (complex? 3)
#t
> (integer? 3.0)
#t
> (exact? 3.0)
#f
> (exact? #e3.0)
#t
>
complex?
real?
rational?
integer?
That's "the tower". If (f? x) is true for some f from that list, then (g?
x) is also true for every g above f in the tower. The internal
representation is undiscoverable in Scheme ("real" doesn't *mean* "HW
floating-point storage" there).
There is no simple relationship between a number's type and
its representation inside a computer. Although most
implementations of Scheme will offer at least two different
representations of 3, these different representations denote
the same integer.
When the focus is on numbers as mathematical values, internal storage format
should be irrelevant to semantics.
More information about the Python-list
mailing list