[Oberon] Negative integer literals in Oberon

Joerg joerg.straube at iaeth.ch
Sun Apr 26 03:04:53 CEST 2020


Assume INTEGER i (* 32 bit *)
i := 7FFFFFFFH;
i := i + 1;

The report does not say that you have to do a range check. i = 80000000H. if this bit combination is signed or unsigned depends on your output procedure: WriteInt vs WriteHex

Assume BYTE b
1) b := 0; b := b - 1;
2) i := -1; b := i;

The report does not say that you have to do a range check. If the compiler does not generate a runtime range check, I propse to not do a compile time range check and allow b := -1;
After 1) and 2)  b = 255; 

br
Jörg

>> Am 26.04.2020 um 00:17 schrieb August Karlstrom <fusionfile at gmail.com>:
>> 
>> On 2020-04-25 18:56, Joerg wrote:
>> I have a clear opinion on this: it is allowed. But we had a kind of similar case a few days back when I was attacked to allow b := -1;
> 
> The language report doesn't say anything about the range of the basic types with the exception of BYTE which is defined as the integers between 0 and 255. Therefor it is implementation-dependent whether or not an integer can be assigned 90909090H. On the other hand it seems reasonable to reject the statement b := -1.
> 
> -- August
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon



More information about the Oberon mailing list