[Oberon] Why no enumeration types?

Chris Burrows cfbsoftware at gmail.com
Wed Jul 28 06:59:30 CEST 2021


> > On Sun, Jul 25, 2021, at 11:06 PM, Timothy Pearson wrote:
> >>
> >> - having manually to create unique numerical constants for each
> >> enumerated value… in fact, for a long list of constants being used to
> >> represent enumerated values, it feels like the safest thing would be to
> >> generate the source using a script
> >>

This was indeed envisaged in the early days of Oberon. In 1991 Niklaus
Wirth wrote a conversion program to convert the bulk of a Modula-2
(with its enumerated types) program to an equivalent Oberon version.
Various versions of this convertor can be downloaded from the
Internet. Search for ModulaToOberon. I also published a version in
2006 which converted Pascal programs instead.

The original source code is included with the MacII Oberon sources:

https://norayr.am/archive/oberon/OberonV4/MacII/Sources/ModulaToOberon/

It can be used to generate a list of constants for an enumeration e.g.
I have just run a test on a GPCP version of the software. The input
file was:

MODULE Enums;

TYPE
  Colour = (Red, Orange, Yellow, Green, Blue, Indigo, Violet);

END Enums.

The resulting output file is:

MODULE Enums;

TYPE
  Colour = INTEGER;
CONST Red = 0; Orange = 1; Yellow = 2; Green = 3; Blue = 4; Indigo =
5; Violet = 6;

END Enums.

Regards,
Chris Burrows
CFB Software
https://www.astrobe.com


More information about the Oberon mailing list