[Oberon] Case statements containing base type labels
joerg.straube at iaeth.ch
joerg.straube at iaeth.ch
Mon Aug 28 13:15:27 CEST 2023
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 at lists.inf.ethz.ch> im Auftrag von August Karlstrom <fusionfile at gmail.com>
Datum: Montag, 28. August 2023 um 12:53
An: oberon at lists.inf.ethz.ch <oberon at 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 at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20230828/f40cf6b8/attachment.html>
More information about the Oberon
mailing list