[Oberon] Negative integer literals in Oberon

Joerg joerg.straube at iaeth.ch
Sat May 2 13:43:17 CEST 2020


This is exactly my point: to allow low level programming the compiler should ignore INTEGER overflow with hex notation.
If you don’t, 90909090H will generate an error on 32bit machine what is NOT the expectation of a low level programmer.

But you‘re right. Perhaps I overloaded the example to make my point with another one: I overdid it a little bit with the amount of Fs.

What I wanted to say was i := 0FFFFFFFFH; should be allowed (but already this overflows normal two’s complement INTEGER arithmetic on a 32bit CPU) This case is not covered in the Oberon report as the semantic of the H operator is not well defined.
Now, even if you ignored overflow, the compiler could still detect whether the hex string has more than 8 digits (ignoring leading 0s in the digit counting)

Whether b := i; should generate a range check or not, is not defined in the Oberon report. If the compiler does not generate a runtime range check for b := i, then b := 300; should not generate a compile time error neither.

br
Jörg

> Am 01.05.2020 um 19:17 schrieb Oleg N. Cher <allot at bk.ru>:
> 
> Jörg пишет:
> 
>> In Oberon-07, you can write
>>  b := 0FFFFFFFFFFFFH;
>>  i := 0FFFFFFFFFFFFH;
>> the results are: b = 255 and i = -1.
> 
> This is some kind of trash and ugliness. Why is overflow not detected?
> 
> The fact that overflow is allowed and it is not caught in any way, generates carelessness and lack of accuracy. This was much better done in Oberon/Oberon-2. IMHO.
> 
>>> 
>>> So I understand the H/L suffix enables the use of hex bit patterns for 32 and 64 bit integers, but does not address the issue for 8 or 16 bit integers.
>>> 
>>> Do you know if there is any way to enable e.g. FF for bytes, or FFFF for shortints? Or whether this was considered?
>>> 
>>> Thanks --
>>> 
>> ------------------------------------------------------------------------
>> --
>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
>> https://lists.inf.ethz.ch/mailman/listinfo/oberon
> 
> --
> 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