[Oberon] Eliminating RETURN statements

Jörg joerg.straube at iaeth.ch
Thu Apr 9 08:17:06 CEST 2020


Chris

I did consider this in one of my internal translation trials as well but decided against it, as the ~(p[i, k] & puzzl[j + k]) seemed a little closer to the original IF-IF. But of course, one might debate ;-)

Jörg

Am 09.04.20, 02:10 schrieb "Oberon im Auftrag von Chris Burrows" <oberon-bounces at lists.inf.ethz.ch im Auftrag von chris at cfbsoftware.com>:

    > -----Original Message-----
    > From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of August
    > Karlstrom
    > Sent: Thursday, 9 April 2020 4:00 AM
    > To: oberon at lists.inf.ethz.ch
    > Subject: Re: [Oberon] Eliminating RETURN statements
    > 
    > Here is an alternative:
    > 
    > 	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?
    
    Regards,
    Chris Burrows
    CFB Software
    https://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