[Oberon] CASE without ELSE

Diego Sardina dsar at eml.cc
Sat Feb 17 23:58:41 CET 2018


On Sat, Feb 17, 2018, at 11:32 PM, Arthur Yefimov wrote:
> 
> Does it mean that CASE statement for pointer/record types work like an IF statement? Does it sequentially check all options one by one until it hits the right one? In this case, what does "CASE" give in comparison to using "IS" clause, i.e. "IF obj IS MyViewer THEN ... ELSIF obj IS ..."?
> 

Yes, it is a syntactic sugar for IF/ELSIF and type guard, nothing more.

This is the reason I don't like the Oberon-2 WITH statement merged in CASE statement since they use two different implementations that lead to confusion (just check recent threads in comp.lang.oberon).

Regarding the possibility of implementing a jump table for typecase, it's not possible due to type extension, you have to know a priori all the hierarchy. This is only possible with final types that Oberon and Oberon-2 don't have (but Component Pascal does have).

If you are interested, this is further discussed in Appel - Modern compiler implementation (in Java) on page 291.






More information about the Oberon mailing list