[Oberon] Alternatives for cases.

Jörg joerg.straube at iaeth.ch
Thu Mar 7 08:13:20 CET 2019


Chris
Looking at your code I assume your compiler subtracts minCaseLabel (in your case "0") from "ch", right?
Jörg

Am 06.03.19, 21:44 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
    > peter at easthope.ca
    > Sent: Thursday, 7 March 2019 6:20 AM
    > To: oberon at lists.inf.ethz.ch
    > Subject: [Oberon] Alternatives for cases.
    > 
    > Hi,
    > 
    > Seeing as alternative techniques for exiting a procedure and for
    > ending interation are popular subjects recently, another question
    > about alternatives.
    > 
    > Elimination of IF and CASE has some aesthetic appeal.
    > Otherwise, is the array technique ever worth using?
    > OK when most elements in the array are distinct?
    > How fast is array indexing compared to jumping?
    > How bad is the additional procedure call?
    > 
    
    This is one of my test CASEs - I hope it's self-explanatory. Try
    implementing that using procedures and see what you think.
    Consider the resulting readability / maintainability / code size as well as
    speed of execution:
    
        IF (ch <= 02FX) OR (ch >= 07BX) THEN 
          INC(others)
        ELSE 
          CASE ch OF
          03AX..040X, 05BX..060X:
            INC(others) |     
          "a", "e", "i", "o", "u":
            INC(vowels);
            INC(letters) |
          "A", "E", "I", "O", "U":
            INC(vowels);
            INC(letters);
            INC(capitals) |
          "b".."d", "f".."h", "j".."n", "p".."t", "v".."z":
            INC(letters) |
          "B".."D", "F".."H", "J".."N", "P".."T", "V".."Z":
            INC(letters);
            INC(capitals) | 
          "0".."9":
            INC(digits)
          END
        END
    
    Regards,
    Chris
    
    Chris Burrows
    CFB Software
    http://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