🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4739

Layout of CASE Statements

#4739
From: COK2
Date: Fri, 31 Mar 1989 13:51
60 lines
2531 bytes
I like the structure of my programs to yell themselves at me.
Hence, the layout of a program is important to me.

Here is how I have laid out CASE statements up to now:
   CASE month OF
   |  jan, mar, may, jul, aug, oct, dec:
            len:= 31
   |  feb:
            IF (year MOD 4 = 0) AND (year MOD 100 <> 0)
               THEN
                  len:= 29
               ELSE
                  len:= 28
            END
   |  apr, jun, sep, nov:
            len:= 30
   END
Note the line of | lined up between the C of CASE and the E of END.
This line helps to show the extent of the CASE statement, and
clearly shows where each arm starts.

Note that the first bar is superfluous --- it is allowed by the 3rd (and
subsequent) edtions of Wirth's "Programming in Modula-2".   The first | is
there to re-inforce the line of | characters.

Recently, I have thought of a new layout for CASE statements.
Here a row of | characters are used to separate the arms of the CASE
statement:
   CASE month OF
   jan, mar, may, jul, aug, oct, dec:
      len:= 31
   |||||||||||||
   feb:
      IF (year MOD 4 = 0) AND (year MOD 100 <> 0)
         THEN
            len:= 29
         ELSE
            len:= 28
      END
   |||||||||||||
   apr, jun, sep, nov:
      len:= 30
   END
I currently have two problems with this:
(a) how long to make the row? --- the length of the line containing CASE?
    or the length of the longest line in the CASE statement?
(b) whether to include a row of | characters both before the first arm
    and after the last arm?
==
IMPORTANT: the following are new electronic mail addresses.
==
Barry Cornelius
==
Computer Science Group, School of Engineering and Applied Science,
University of Durham, Durham, DH1 3LE, England
              JANET:       Barry.Cornelius@uk.ac.durham
              Internet:    Barry.Cornelius%durham.ac.uk@cunyvm.cuny.edu
              UUCP:        ...ukc!cs.nott.ac.uk!bjc
              BITNET/EARN: Barry.Cornelius%DURHAM@AC.UK
Tel: Durham (091 or +44 91) 374 2638, Secretary: 374 2630, Fax: 374 3741
Technical Details
Message-ID: <INFO-M2%89033108531194@UCF1VM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!MTS.DURHAM.AC.UK!COK2

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!MTS.DURHAM.AC.UK!COK2
From: COK2@MTS.DURHAM.AC.UK
Newsgroups: comp.lang.modula2
Subject: Layout of CASE Statements
Message-ID: <INFO-M2%89033108531194@UCF1VM>
Date: 31 Mar 89 13:51:16 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: Modula2 List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu>
Organization: The Internet
Lines: 60