[Oberon] How to write this program in Oberon-07?

Oleg N. Cher allot at bk.ru
Fri Jan 28 02:01:16 CET 2022


Hi Chris and all,

But of course you are aware that the latest revisions of the Oberon-07 
language report say nothing about the fact that CASE should warn the 
programmer about an encountered label that is not in the list?

Yeah, the report doesn't say anything about that.

So this question, as well as many non-obvious points in Oberon-07, are 
left to the language's implementers to solve. And in the description of 
Oberon-2 and Component Pascal there is explicitly about CASE behavior.

So ELSE for CASE could be useful to include at least ASSERT(FALSE). But 
since this is not possible, we make our poor programming even poorer.


Chris Burrows пишет:
> On Tue, Jan 25, 2022 at 4:06 AM Jörg <joerg.straube at iaeth.ch 
> <mailto:joerg.straube at iaeth.ch>> wrote:
> 
>     __ __
> 
>     There is a long debate whether an ELSE in a CASE is something good
>     or bad.____
> 
>     That’s a little bit comparable to LOOP/EXIT: At first sight ELSE
>     looks hand. But if you really had to debug complicated code with a
>     lot of CASE statements you will conclude that the ELSE is quite
>     dangerous.____
> 
>     Let’s assume you forgot an important CASE. Instead of being trapped
>     (default behaviour of an uncovered CASE without ELSE) the ELSE
>     catches it, the code goes on with perhaps totally wrong variable
>     settings and the code error (forgotten CASE) is mostly unnoticed!
> 
> 
>  I agree. Similar potential pitfalls can occur in IF-THEN-ELSIF ladders. 
> It can be a good defensive programming technique to add to the end of these:
> 
> ELSE
>   ASSERT(FALSE)
> END;
> 
> That will trap current (or future, if related code is changed) 
> possibilities that have been overlooked. As a real-life example of this 
> I would have saved myself several hours of head-banging this week if 
> problematic code I have been investigating had been implemented this 
> way. I was able to replace it with a (more efficient) numeric CASE 
> statement on this occasion.
> 
> --
> Chris Burrows
> CFB Software
> http://www.astrobe.com
> 
> 
> ------------------------------------------------------------------------
> 
> --
> 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