PEP0238 lament
Grant Edwards
grante at visi.com
Tue Jul 24 13:10:40 EDT 2001
In article <slrn.pl.9lqvmg.n1b.qrczak at qrnik.zagroda>, Marcin 'Qrczak' Kowalczyk wrote:
>>>> 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,
For some definitions of "practical". My definition of
practical doesn't include changing the meaning of "/" between
minor revs of a language. ;)
To be honest, I would prefer than int/float or float/int throws
an exception (and should possibly do the same for "+", "-",
etc.). If you want to mix them, then tell the compiler what to
do. Explicit is better than implicit:
y = x/float(i)
j = int(x)/i
>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.
Why?
>Without them some reasonable code is hard to write.
I guess I never ran into such a situation.
--
Grant Edwards grante Yow! Was my SOY LOAF left
at out in th'RAIN? It tastes
visi.com REAL GOOD!!
More information about the Python-list
mailing list