[Oberon] SYSTEM Modules
informujo at aon.at
Mon Nov 12 20:48:26 CET 2018
On 12.11.18 08:53, Chris Burrows wrote:
> 2. ADR and GET are readonly so they are not inherently unsafe.
> However, they are required for PUT and COPY to be effective so they
> are unsafe by association.
Also, even trying to get an integer represenation of the address of a
variable may fail—for example, if the variable is stored in a register,
or non-linear memory space is used.
And trying to read from memory can crash the program due to wrong
alignment or access to a protected memory area.
> 3. VAL falls into the category of it depends ...
> SYSTEM.VAL(SET, intval), SYSTEM.VAL(CHAR, intval),
> SYSTEM.VAL(INTEGER, charval) are as harmless as ORD and CHR. All are
> inherently non-portable however.
Contrary to ORD and CHR they also break type safety.
> 4. BIT and SIZE I'm not so sure about. They are both readonly so I
> can't see how you could corrupt a system with their use.
BIT tries to read memory, so it belongs into the same group as GET. SIZE
seems to be useful only for preparing "unsafe" operations.
But I agree that the distinction between "safe" and "unsafe" is not
Maybe a better criterion would be, if a language feature potentially
breaks the abstraction of a high-level type-safe programming language.
Then, it is clear that ORD and CHR are on the safe side, because we can
always rely on getting a valid character code from ORD and being able to
convert it back to the original character with CHR.
But we can not rely on SYSTEM.VAL(INTEGER,setval) to give us an integer
value which can be converted back to a valid set value with
SYSTEM.VAL(SET,integerval), because sets may be implemented in a way
incompatible with integer values.
More information about the Oberon