[Oberon] LOOP conversion

Chris Burrows chris at cfbsoftware.com
Mon Jan 4 10:33:26 CET 2021


> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> Bernhard Treutwein
> Sent: Monday, 4 January 2021 7:46 PM
> To: oberon at lists.inf.ethz.ch
> Subject: [Oberon] LOOP conversion
> 
> Our russian friends had a very long thread about conversion of LOOP -
> EXIT
> 	https://forum.oberoncore.ru/viewtopic.php?f=82&t=2547
> it is readable and understandable with Google translate ...
> 
> I personally think that deliberate and good use of LOOP is not that
> bad.
> 
> E.g., I find
> 
> LOOP
>   Step;
>   IF cond THEN EXIT END;
>   CodeBlock
> END
> 
> more attractive and readable than
> 
> Step;
> WHILE ~cond DO
>   CodeBlock;
>   Step
> END
> 

If an action in a loop is always performed at least once, a REPEAT loop is
usually preferable to WHILE.

This then becomes:

REPEAT
  Step;
  IF ~cond THEN CodeBlock END
UNTIL cond

Regards,
Chris

Chris Burrows
CFB Software
https://www.astrobe.com





More information about the Oberon mailing list