[Oberon] Case statements containing base type labels

Paul Reed paulreed at paddedcell.com
Mon Aug 28 14:19:06 CEST 2023


So I think the answer to the original question is that *in the reference 
implementation, not the report* it is well-defined, and the order does 
matter: it's a cascaded if...then...else of type tests;

However that's perhaps against the original spirit of CASE, and what it 
*should* be in general is perhaps what Joerg said, the base type case is 
effectively ELSE, and might even preferably be implemented that way...

I love it when everyone's right ;-)

Cheers,
Paul


On 2023-08-28 13:05, joerg.straube at iaeth.ch wrote:
> Diego
> 
> Okay. Then it can be seen as ELSE of the CASE 😊
> 
> Jörg
> 
> Von: Oberon <oberon-bounces at lists.inf.ethz.ch> im Auftrag von Diego
> Sardina <dsar at eml.cc>
> Datum: Montag, 28. August 2023 um 13:40
> An: oberon at lists.inf.ethz.ch <oberon at lists.inf.ethz.ch>
> Betreff: Re: [Oberon] Case statements containing base type labels
> 
> On Mon, Aug 28, 2023, at 13:15, joerg.straube at iaeth.ch wrote:
> 
>> 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
> 
> A record type is also an extension of itself. So that is valid.
> 
> --
> 
> Diego Sardina
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related 
> systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon


More information about the Oberon mailing list