[Oberon] Eliminating RETURN statements
Jörg
joerg.straube at iaeth.ch
Thu Apr 9 11:25:20 CEST 2020
Hans
The generated code length of the two solutions is the same.
Jörg
Am 09.04.20, 09:22 schrieb "Oberon im Auftrag von Hans Klaver" <oberon-bounces at lists.inf.ethz.ch im Auftrag von hklaver at dds.nl>:
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
--
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