🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4743

Re: Layout of CASE Statements

#4743
From: dick Dick Karpinski
Date: Fri, 31 Mar 1989 22:29
39 lines
1941 bytes
In article <INFO-M2%89033108531194@UCF1VM> Modula2 List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu> writes:
>I like the structure of my programs to yell themselves at me.
OK, try this idea (and note correction for February)

    CASE month OF

    |||| (* long months *)
       jan, mar, may, jul, aug, oct, dec:
          len := 31

    |||| (* the variable length month *)
       feb:
          IF  (year MOD   4  = 0) AND 
	     ((year MOD 100 <> 0)  OR  (year MOD 400 = 0))
             THEN
                len := 29
             ELSE
                len := 28
          END (* IF (year ... *)

    |||| (* medium size months *)
       apr, jun, sep, nov:
          len := 30

    END (* CASE month OF *)

While this uses even more whitespace than I would, myself, it seems
to shout the structure adequately and provide ample opportunity to
add commentary.  I hate unmarked ENDs.  Each case is treated in
exactly the same way so nothing need be fixed up for a new first or
last case.  The additional indentation and blank lines emphasize
the separation of cases visually.  What more could you ask?

Dick

Dick Karpinski  Manager of Minicomputer Services, UCSF Computer Center
Domain: dick@cca.ucsf.edu                      (415) 476-4529 (11-7)
BITNET:  dick@ucsfcca or dick@ucsfvm           (415) 658-6803 (Home)
USPS:  U-76 UCSF, San Francisco, CA 94143-0704 (415) 658-3797 (ans)
Technical Details
Message-ID: <1791@ucsfcca.ucsf.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!agate!ucbvax!ucsfcgl!cca.ucsf.edu!ucsfccb!dick
References: <INFO-M2%89033108531194@UCF1VM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!agate!ucbvax!ucsfcgl!cca.ucsf.edu!ucsfccb!dick
From: dick@ucsfccb..ucsf.edu (Dick Karpinski)
Newsgroups: comp.lang.modula2
Subject: Re: Layout of CASE Statements
Summary: add commentary, fix algorithm
Message-ID: <1791@ucsfcca.ucsf.edu>
Date: 31 Mar 89 22:29:05 GMT
References: <INFO-M2%89033108531194@UCF1VM>
Sender: root@cca.ucsf.edu
Reply-To: dick@ucsfccb.UUCP (Dick Karpinski)
Organization: UCSF, Computer Center
Lines: 39