[Oberon] Type compatibility in Oberon

Jörg joerg.straube at iaeth.ch
Sat May 2 11:08:16 CEST 2020


> i := SYSTEM.VAL(INTEGER, 9502F900H)

Type casting does not solve the issue. The issue is: what is the value 9502F900H?
Is it 2500000000 or is it -1794967296? The Oberon language needs to define something I would call „value casting“.

> Otherwise, what would you propose as a solution to your problem? 

Firstly, it‘s not my problem. It‘s all compiler writer’s problem as they have to implement the semantic of the H suffix operator.

To allow low level programming and meet the expectation of most programmers I would define the semantic of the H operator as follows:

„A sequence of hex digits ending with suffix H allows to cast the value that fits into a CPU register into an Oberon INTEGER“

If your CPU supports two different register sizes and arithmetic on eg 32 bit and 64 bit (eg INTEGER and LONGINT in Oberon, not foreseen in Oberon-07 though), you’ll need two different value cast operators eg H and L, as the result of value cast operator „H“ and value cast operator „L“ of the hex digits „90909090“ is different.


More information about the Oberon mailing list