comp.lang.ada
 help / color / mirror / Atom feed
From: "Tom Phinney" <tom.phinney@ibm.net>
Subject: Re: Ada95 Pretty-Printers
Date: 1997/06/14
Date: 1997-06-14T00:00:00+00:00	[thread overview]
Message-ID: <01bc7874$c9e9e660$aae32581@anonymous> (raw)
In-Reply-To: 33A157AA.1F2F3650@link.com


Samuel Mize <smize@link.com> wrote in article <33A157AA.1F2F3650@link.com>...
> John G. Volan (quoting himself) wrote that Apex does this:

<examples omitted, can be found in many prior posts in this thread>

> All this is in accordance with the indentation shown in the ARM, but I
> personally just hate it.  I don't think a loop or block should be indented
> just because it's named.  I feel that the "when" clauses are a parallel
> part of the structure.  It makes no more sense to indent "when" or "then"
> than it does to indent "else."  Obviously, this is all just personal
> opinion.  But I'm glad to see a smart guy and a significant company
> agreeing with me :-) .
-------
The whole point in the "comb" structure was 

(1) to have a structure with bounds on both ends -- the lesson learned from the
unclosed Pascal constructs like "if" (without an "end if");

(2) to have a series of "tines" between the ends of the comb to separate the
intermediate portions of the construct.

What's the point of putting a second level of indentation on the inner part of
the comb relative to the comb ends?  Why should some tines in some combs be
indented, and others not?  My personal practice is to put the "tine" keywords
either as the last or first lexeme(s) of each line, with the choice made for
readability.  This leads (with blank lines omitted when the constructs are
parallel and visually small) to

 if <Boolean-expression> then
   <sequence-of-statements>

 elsif <boolean-expression> then
   <sequence-of-statements>

 else
   <sequence-of-statements>
 end if;

when the boolean expression is small enough to fit on a single line, but any
one of the if or elsif clauses could change to a multi-line form when the
expression itself requires multiple lines, as in 

 if <very-long-multi-line-
                     boolean-expression> 
 then
   <sequence-of-statements>

 elsif <boolean-expression> then
   <sequence-of-statements>

 else
   <sequence-of-statements>
 end if;

A similar approach applies to loop, case, and the other "comb" structures.  In
fact, I frequently use the same syntax for procedure, etc. definitions, with
the "is" moving to an isolated line when that provides better readability and a
more intelligible comb structure.  This same approach works for VHDL (no
surprise :-), and has been used in a number of projects where readability was a
major issue.

Tom Phinney
Honeywell




  parent reply	other threads:[~1997-06-14  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <339C58A6.4D5A@sprintmail.com>
1997-06-10  0:00 ` Ada95 Pretty-Printers Anonymous
1997-06-10  0:00   ` John G. Volan
1997-06-10  0:00 ` Samuel Mize
1997-06-10  0:00   ` stuman
1997-06-10  0:00   ` John G. Volan
1997-06-11  0:00     ` Samuel Mize
1997-06-12  0:00     ` John G. Volan
1997-06-13  0:00       ` Samuel Mize
1997-06-14  0:00         ` Robert Dewar
1997-06-14  0:00           ` Samuel Mize
1997-06-14  0:00             ` Robert Dewar
1997-06-14  0:00         ` Tom Phinney [this message]
1997-06-12  0:00     ` Robert Dewar
1997-06-10  0:00   ` John G. Volan
1997-06-10  0:00     ` Spam Hater
1997-06-10  0:00       ` Spam Hater
1997-06-16  0:00     ` Greg Gicca @pulsar
1997-06-11  0:00 ` Matthew Heaney
1997-06-11  0:00 ` Rolf Ebert
1997-06-11  0:00   ` John G. Volan
1997-06-12  0:00 ` Jeff Burns
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox