int/long unification hides bugs
Steve Holden
steve at holdenweb.com
Wed Oct 27 07:58:18 EDT 2004
kartik wrote:
> "Terry Reedy" <tjreedy at udel.edu> wrote in message news:<mailman.5480.1098763791.5135.python-list at python.org>...
>
>>"kartik" <kartick_vaddadi at yahoo.com> wrote in message
>>news:940ee3e8.0410251927.38347d92 at posting.google.com...
>>
>>>1)catching overflow bugs in the language itself frees u from writing
>>>overflow tests.
>>
>>It is a fundamental characteristic of counts and integers that adding 1 is
>>always valid. Given that, raising an overflow exception is itself a bug,
>>one that Python had and has now eliminated.
>>
>>If one wishes to work with residue classes mod n, +1 is also still always
>>valid. It is just that (n-1) + 1 is 0 instead of n. So again, raising an
>>overflow error is a bug.
>
>
> i don't care what mathematical properties are satisfied; what matters
> is to what extent the type system helps me in writing bug-free code
>
... and the point most of your respondents are trying to make is that an
arbitrary restriction - ANY arbitrary restriction - on the upper limit
of integers is unhelpful, and that's precisely why it's been removed
from the language.
>
>>[...]However, the limit n could be
>>anything, so fixing it at, say, 2**31 - 1 is almost always useless.
>
>
> i dont think so. if it catches bugs that cause numbers to increase
> beyond 2**31, that's valuable.
>
But only if an increase beyond 2**31 IS a bug, which for many problem
domains it isn't. Usually the required upper limit is either above or
below 2**31, which is why that limit (or 2**63, or 2**7) is useless and
unhelpful.
>>The use of fixed range ints is a space-time machine performance hack that
>>has been costly in human thought time.
>
>
> on what basis do u say that
>
A few more years' programming experience will teach you the truth of
this assertion. It appears that no amount of good advice will change
your opinion in the meantime.
regards
Steve
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
More information about the Python-list
mailing list