[Oberon] Bit-fiddling: SETs and type casts in Oberon-07

Chris Burrows cfbsoftware at gmail.com
Mon Aug 8 06:00:10 CEST 2022


On Mon, Aug 8, 2022 at 5:23 AM Hans Klaver <hklaver at dds.nl> wrote:

> I would rather have my Oberon-07 compiler to accept the following (my
> responsibility for the correct result):
>
>  VAR ch: CHAR;
>  ...
>  EXCL(SYSTEM.VAL(SET, ch), 5)   (* cast CHAR to SET and clear bit 5 *)
>  RETURN ch
>  ...
>
> My questions now are:
> - the behaviour regarding SYSTEM.VAL and EXCL of which of the two above
> mentioned compilers do you like best?
> - do you know an Oberon-07 compiler that could compile the last lines of
> code, and what do you think of it?
>
> In other words: what is your opinion about the desired behaviour of
> procedures SYSTEM.VAL and EXCL in an ideal Oberon-07 compiler?
>
>
The Oberon-07 report states:

EXCL(v, x) is equivalent to v := v - {x}.  (* where v is a variable not an
expression *)

Hence trying to write EXCL(SYSTEM.VAL(SET, ch), 5) would be equivalent to
writing:

SYSTEM.VAL(SET, ch) := SYSTEM.VAL(SET, ch) - {5}

To me, that is as wrong as trying to write something like:

ORD(ch) := ORD(ch) + 1

or INC(ORD(ch))

As for the other part of your question I would hope that an implementation
of SYSTEM.VAL would only perform a typecast if the size of the source and
target were the same and would otherwise result in an error, or at the very
least, a warning.

Regards,
Chris Burrows
CFB Software
https://www.astrobe.com.RISC5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20220808/44f9e016/attachment.html>


More information about the Oberon mailing list