[Oberon] Bit-fiddling: SETs and type casts in Oberon-07
Hans Klaver
hklaver at dds.nl
Tue Aug 9 13:01:38 CEST 2022
Hi Jörg,
> Generally - although defined in the language and not in module SYSTEM - code using ORD() is not portable.
>
> i := ORD(ch); (* is not portable as the charset is not defined in the Oberon-07 report *)
Within one charset, even if it has a varying number of bytes (like UTF-8), is Oberon's ORD(ch) guaranteed to work properly for this whole charset?
> i := ORD(bool); (* is not portable as the Oberon-07 reports does not define the representation of TRUE and FALSE *)
> i := ORD(set); (* is not portable as the bit numbering is not defined *)
I noticed that ORD(bool) is used in function procedure Input.Available of PO; there it is assumed that they are INTEGER-sized and that TRUE = 1 and FALSE = 0. Isn't that the de-facto standard?
And isn't the de-facto standard that element 0 of a SET should be the least significant bit of the variable?
Things like endianness and byte-alignment might already be tackled by the requirement that only INTEGER-sized variables are allowed to be casted to SET.
Are these issues not defined in the Oberon-07 report on purpose? And if so, why not?
If there is no specific reason to *not* define them in an 'ideal' Oberon-07 report, maybe these definitions should be added in a future version to make the language more portable.
Regards,
Hans
More information about the Oberon
mailing list