Path: 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: Date: 31 Mar 89 13:51:16 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Modula2 List Organization: The Internet Lines: 60 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