[M3devel] integer overflow and for loops

Coleburn, Randy rcolebur at SCIRES.COM
Wed Jan 13 19:00:02 CET 2010


I agree completely.  

(I know I said something about overflow checking before, but I mispoke; my intent was to ensure the implementation had a way we could turn this on because I was under the impression the current implementation hadn't evolved that far even though FloatMode gave the interface.)

--Randy Coleburn

________________________________________
From: Tony Hosking [hosking at cs.purdue.edu]
Sent: Wednesday, January 13, 2010 10:47 AM
To: Roland Illig
Cc: m3devel
Subject: Re: [M3devel] integer overflow and for loops

Their is a fine line to tread here between prohibiting perceived "bad" things happening and leaving the language design permissive enough to have an efficient implementation.  In the case of overflow I am not convinced it is so evil that it should be prohibited in the implementation.  In fact, one can argue that because current hardware does not uniformly treat integer overflow in ways that yield to efficient implementations the retaining the ambiguity is the right compromise.  This does not make the language any less safe.  A programmer cannot safely conjure values out of thin air.  And so long as he/she understands about integer overflow then the effects are at least entirely predictable.  Gguard against overflow is straightforward enough to do:

VAR upper: [0..LAST(INTEGER)-1] := bound;
FOR j = lower TO upper DO ... END;

On 13 Jan 2010, at 02:33, Roland Illig wrote:

> Jay K schrieb:
>> http://www.roland-illig.de/articles/modula-3-for-loop.pdf
>
> My main point in that article was not the integer overflow but the fact of having an ugly sentence like "don't use the FOR loop for large numbers" in the language definition. Additionally, one would not expect the FOR loop to loop endlessly. These are the things I wanted to fix back then.
>
> Roland



More information about the M3devel mailing list