Next: Name Casing, Previous: Formatting Comments, Up: Formatting Rules
In several cases the suggested layout in the Ada Reference Manual includes an extra level of indentation that many programmers prefer to avoid. The affected cases include:
In compact mode (when GNAT style layout or compact layout is set),
the pretty printer uses one level of indentation instead
of two. This is achieved in the record definition and record representation
clause cases by putting the record
keyword on the same line as the
start of the declaration or representation clause, and in the block and loop
case by putting the block or loop header on the same line as the statement
identifier.
The difference between GNAT style -l1 and compact -l2 layout on the one hand, and uncompact layout -l3 on the other hand, can be illustrated by the following examples:
GNAT style, compact layout Uncompact layout type q is record type q is a : integer; record b : integer; a : integer; end record; b : integer; end record; for q use record for q use a at 0 range 0 .. 31; record b at 4 range 0 .. 31; a at 0 range 0 .. 31; end record; b at 4 range 0 .. 31; end record; Block : declare Block : A : Integer := 3; declare begin A : Integer := 3; Proc (A, A); begin end Block; Proc (A, A); end Block; Clear : for J in 1 .. 10 loop Clear : A (J) := 0; for J in 1 .. 10 loop end loop Clear; A (J) := 0; end loop Clear; |
A further difference between GNAT style layout and compact layout is that GNAT style layout inserts empty lines as separation for compound statements, return statements and bodies.
Note that the layout specified by --separate-stmt-name for named block and loop statements overrides the layout defined by these constructs by -l1, -l2 or -l3 option.