[Oberon] Eliminating RETURN statements

Hans Klaver hklaver at dds.nl
Thu Apr 9 09:21:50 CEST 2020


Chris Burrows wrote:

>> 	PROCEDURE Fit (i, j: INTEGER): BOOLEAN;
>> 		VAR k: INTEGER;
>> 	BEGIN
>> 		k := 0;
>> 		WHILE (k <= piecemax[i]) & ~(p[i, k] & puzzl[j + k]) DO
>> 			INC(k)
>> 		END
>> 	RETURN k > piecemax[i]
>> 	END Fit;
>> 
>> 
> 
> According to one of De Morgan's Laws 
> 
> i.e.   ~(A AND B) --> (~A OR ~B)
> 
> the WHILE expression can be simplified to:
> 
>    WHILE (k <= piecemax[i]) & (~p[i, k] OR ~puzzl[j + k]) DO
> 
> However, I'm not convinced this is simpler. What do you think?

I would say that simplification means 'bringing to a form with less operators', and here there are (slightly) more operators on the right side. 
So I do not consider it a simplification.

--
Hans Klaver



More information about the Oberon mailing list