[Oberon] Negative integer literals in Oberon

Jörg joerg.straube at iaeth.ch
Mon Apr 27 21:40:34 CEST 2020

Here, the code uses SYSTEM and I know its not portable by definition, or at least I must be careful when porting.

32 bit literals seem useful in low level programming.
If you have a strict compiler, like VOC, it’s far from obvious how to do what you want to do.

If you want to pass 9090909090H and your machine has 63 bit INTEGERs
  9090909090H - 100000000H  does the trick
If your machine has 31 bit INTEGERs
  -6F6F6F70H does the trick.

Both methods are there to just overcome the compiler restrictions.
That’s not what I call a programming language suitable to low level programming.
As said everything can be done in Oberon and I‘m fan of Oberon, but a really good high level abstraction (=language construct) for bit programming is unfortunately missing.
Br Jörg

> Am 27.04.2020 um 20:22 schrieb August Karlstrom <fusionfile at gmail.com>:
> On 2020-04-27 15:12, Jörg wrote:
>> Puristically speaking, Oberon can't be used for low level programming
>> as too much things are left to the implementation. 
> I don't think I agree. As mentioned by Chris, in a low-level module you can assert that the type INTEGER has the desired properties and then assume that the requirements are met in the rest of the code:
>    ASSERT(0FFFFFFFFH = -1) (*require two's complement*)
>    ...
>> An abstraction like "BITFIELD" or "BIT32" or so is missing. This new
>> base type is not identical to INTEGER as it does not leave the
>> implementation open, but defines exactly how bits are numbered, and
>> how many bits there are. If you use the base type INTEGER where you
>> basically want to manipulate bits, these two concepts clash. On this
>> bit type you can use bitwise AND, OR, XOR, can shift etc.
> The basic philosophy of the Oberon language report is to describe an abstract language which does contain references to a computer or computing mechanism. This makes the language timeless. In the future 32-bit computing will probably be completely outdated.
> -- 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