August
In Oberon-07 it is defined as follows:
The type T of the case expression (case variable) may also be a record or pointer type. Then the
case labels
must be extensions of T, and in the statements Si labelled by Ti, the case variable is
considered as of type Ti.
PROCEDURE Draw (s: Shape)
BEGIN
CASE s OF
Rectangle: ... |
Circle: ... |
Shape: ... this is not allowed as “Shape” is not an extension of “Shape”
END
END Draw;
Jörg
Von:
Oberon <oberon-bounces@lists.inf.ethz.ch> im Auftrag von August Karlstrom <fusionfile@gmail.com>
Datum: Montag, 28. August 2023 um 12:53
An: oberon@lists.inf.ethz.ch <oberon@lists.inf.ethz.ch>
Betreff: [Oberon] Case statements containing base type labels
Given the declarations
Shape = RECORD x, y: REAL END
Rectangle = RECORD (Shape) w, h: REAL END
Circle = RECORD (Shape) r: REAL END
does a case statement containing labels for all three types have well
defined behavior?
CASE s OF
Rectangle: ... |
Circle: ... |
Shape: ...
END
In this case a rectangle and a circle respectively is also a shape so
it's not clear what label is selected and the order of the labels should
not matter.
Regards,
August
--
Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon