On 2021-01-06 19:41, peter@easthope.ca wrote:
Unrefined oberservations.
(1) Isomorphism exists between LOOP texts and WHILE texts.
(2) Loops can be nested in a tree structure. At each level there can be multiple loops and the number of levels is arbitrary.
(3) In the general case a continuation flag is needed for each level. Eg. VAR continue0, continue1 ... : BOOLEAN;
(4) A LOOP having only one exit in the form "LOOP IF a THEN EXIT END; ... END" can be replaced with "WHILE ~a DO ... END".
(5) A LOOP having only one exit in the form "LOOP ... IF a THEN EXIT END END" can be replaced with "REPEAT ... UNTIL a".
(6) Pattern "LOOP statements0 IF a THEN EXIT END; statements1 END" becomes "continue := TRUE; WHILE continue DO; statements0 IF a THEN continue := FALSE ELSE statements1 END END".
We should also note that this is only the first step to make the program compile. If comprehensibility is the goal the variables named "continue", "done" etc. should ideally be replaced with something more descriptive and specific. When skimming through the program a loop like continue := TRUE; WHILE continue DO ... END; is not very informative. After the loop we know that `continue' is false but what does that imply? -- August