[Oberon] Easter eggs in Oberon

Joerg joerg.straube at iaeth.ch
Mon Apr 13 17:36:31 CEST 2020


August

The word „numeric type“ is not clearly defined in the report.

Eg. is BYTE part of the numeric types?
Or is INTEGER part of the numeric type?
If it was you sould be able to write i := i / 3;  (as / is defined on numeric types)...

The Oberon report leaves some room for interpretation... (especially for corner cases)

b := -2;  is equivalent to b := 254;

br
Jörg

> Am 13.04.2020 um 15:16 schrieb August Karlstrom <fusionfile at gmail.com>:
> 
> On 2020-04-12 13:00, Joerg wrote:
>> There is no „byte multiplication“; 
> 
> The language report says that
> 
> "The operators +, −, *, and / apply to operands of numeric types. Both operands must be of the same type, which is also the type of the result."
> 
> If both operands have type BYTE then multiplication is BYTE multiplication as far as the language is concerned. It will probably be implemented using 32-bit or 64-bit multiplication but that's an implementation detail.
> 
>> the type BYTE modifies the assignment not the multiplication;
>> After these statements
>>     b := -2;
> 
> In the language report BYTE is defined as "the integers between 0 and 255" and "The type BYTE is compatible with the type INTEGER, and vice-versa." This implies that INTEGER is compatible with BYTE *only* if the value is between 0 and 255. Therefor the above statement is invalid.
> 
>>     b := b * 256;
> 
> Here, b on the right hand side is interpreted as an INTEGER and the type of the product is INTEGER. The result is then interpreted as a BYTE and assigned to b. The statement above is well defined only when b = 0.
> 
>> b is 0 although the multiplication results in 65024. Can be verified by these statements >      b := -2;
>>     i := b * 256;
> When the result is undefined you can potentially get anything.
> 
> 
> -- 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