Next: Subprograms, Previous: Expressions and Names, Up: Top [Contents][Index]
if, elsif or else keywords fit on the
same line with the condition and the then keyword, then the
statement is formatted as follows:
if condition then
...
elsif condition then
...
else
...
end if;
When the above layout is not possible, then should be aligned
with if, and conditions should preferably be split before an
and or or keyword a follows:
if long_condition_that_has_to_be_split
and then continued_on_the_next_line
then
...
end if;
The elsif, else and end if always line up with
the if keyword. The preferred location for splitting the line
is before and or or. The continuation of a condition is
indented with two spaces or as many as needed to make nesting clear.
As an exception, if conditions are closely related either of the
following is allowed:
if x = lakdsjfhlkashfdlkflkdsalkhfsalkdhflkjdsahf
or else
x = asldkjhalkdsjfhhfd
or else
x = asdfadsfadsf
then
...
end if;
if x = lakdsjfhlkashfdlkflkdsalkhfsalkdhflkjdsahf or else
x = asldkjhalkdsjfhhfd or else
x = asdfadsfadsf
then
...
end if;
and then,
or else), except when the operands are boolean variables
or boolean constants.
if statements are indented two characters:
if this_complex_condition
and then that_other_one
and then one_last_one
then
...
end if;
There are some cases where complex conditionals can be laid out in manners that do not follow these rules to preserve better parallelism between branches, e.g.
if xyz.abc (gef) = 'c'
or else
xyz.abc (gef) = 'x'
then
...
end if;
if block is preceded and followed by a blank line, except
where it begins or ends a sequence_of_statements.
A := 5;
if A = 5 then
null;
end if;
A := 6;
case statements, the extra indentation
can be saved by aligning the when clauses with the opening case.
case expression is
when condition =>
...
when condition =>
...
end case;
for or while on one line with the
condition and the loop keyword.
for J in S'Range loop
...
end loop;
If the condition is too long, split the condition (see “If
statements” above) and align loop with the for or
while keyword.
while long_condition_that_has_to_be_split
and then continued_on_the_next_line
loop
...
end loop;
If the loop_statement has an identifier, it is laid out as follows:
Outer : while not condition loop
...
end Outer;
declare (optional), begin and end words
are aligned, except when the block_statement is named. There
is a blank line before the begin keyword:
Some_Block : declare
...
begin
...
end Some_Block;
Next: Subprograms, Previous: Expressions and Names, Up: Top [Contents][Index]