[Oberon] Case statements containing base type labels

Diego Sardina dsar at eml.cc
Thu Aug 31 00:01:33 CEST 2023

Unfortunately I didn't have much time to partecipate to this interesting conversation, however I have already talked in the past about the CASE/WITH statements.

I agree it was a bad idea to merge WITH in the CASE statement, in all Wirth languages the CASE statement was always implemented as a jump table (of course I'm excluding Turbo Pascal and the other variants that are not made directly by Wirth). The WITH statement requires another kind of code generation.

Regarding the implementation of the WITH statement, in an extensible system or in an environment where new classes are added in the hierarchy, the only implementation possible is the sequence of IF, ELSIF, etc.
To generate a jump table all the classes must be known a priori. Adding a new class (even in another module) means to rebuild the jump table and the module that uses it (breaking separate compilation). A jump table could be implemented for Component Pascal WITH statement for those hierarchies that are closed and can't be extended anymore (or "final" with Java terminology).

This is also discussed in Appel - Modern Compiler Implementation in Java (pages 291 and 292), where the author talks about the Modula-3 TYPECASE.

I extracted the part and uploaded in the link below (it will be removed in 30 days since it's protected material).


Diego Sardina

More information about the Oberon mailing list