Path: 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: Sender: root@cca.ucsf.edu Reply-To: dick@ucsfccb.UUCP (Dick Karpinski) Organization: UCSF, Computer Center Lines: 39 In article Modula2 List 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)