[Oberon] CASE without ELSE

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Sun Feb 18 22:37:02 CET 2018


    > > Does it mean that CASE statement for pointer/
    > > record types work like an IF statement?

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

A key difference to the IF statement

  IF t IS T1 THEN S1
  ELSIF t IS T2 THEN S2
   ...
  END

is that in the CASE statement

   CASE t OF
      T1: S1 |
      T2: S2 | 
       ...
    END

the dynamic type t of the case expression is set to the type of the selected case, i.e. in the statements S1 labeled by T1, the case variable t is considered as of type T1, etc.

This implies that no type guard t(T1) is needed in S1, etc, i.e. one can just write t instead.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20180218/d72f2544/attachment.html>


More information about the Oberon mailing list