[Oberon] Alternatives for cases.

Chris Burrows chris at cfbsoftware.com
Wed Mar 6 21:43:32 CET 2019


> -----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





More information about the Oberon mailing list