[Lazarus] Auto indentation

Hans-Peter Diettrich DrDiettrich1 at aol.com
Fri Nov 6 08:35:32 CET 2009


Jürgen Hestermann schrieb:

>>> And that's something *I* don't like. You never know which END belongs 
>>> to wheach BEGIN. I always column align all ENDs to their 
>>> corresponding BEGINs.
>> You missed the second part of my argumentation. I'm thinking in the 
>> superior Modula syntax, that does not require begin-end pairs around 
>> statement sequences.
> 
> I am not sure why you mention the Modula syntax. I thought we are 
> talking about Pascal here. And Pascal requires the begin-end pairs 
> (unless it is a single statement). And there is a logic behind it. I 
> always see directly which block is related to the IF (WHILE, REPEAT, 
> ...) statement:
> 
> -----------------
> if a then
>    begin
>    xxxxxx;
>    yyyyyy;
>    ....
>    zzzzzz;
>    end;
> aaaaa;
> bbbbb;
> ccccc;
> -----------------
> 
> -----------------
> if a then
>    xxxxxx;
> aaaaa;
> bbbbb;
> ccccc;
> -----------------

The indentation allows to identify the block ranges, without any optical 
special search for BEGIN and END keywords - only the *formatter* must 
deal with the concrete syntax.

> And if the statement or block is very short I can put the whole on one 
> line:
> 
> -----------------
> if a then begin xxxxxx yyyyyy .... zzzzzz end;

That's questionable practice. It's impossible to set an breakpoint into 
the body of the conditional statement.


> I *never* put deeper level commands/blocks on the same column (including 
> BEGIN/END) and I *always* align the BEGIN/ENDs.

I align the *lines*, *containing* BEGIN/ENDs ;-)

> The BEGIN/ENDs delimit 
> the block and are part of it so IMO they should be treated the same as 
> all other commands of the block and be aligned with them.

There exist substancially different opinions about the alignment of 
BEGIN/ENDs - should they align with their parent statement or be 
indented, and should their content be aligned or indented. As long as 
the extra-line blockers <g> cannot agree about the one and only 
acceptable solution, I feel free to ignore that debate and move the 
block delimiters to the next best place, saving one or more lines in my 
code with every single block.

DoDi





More information about the Lazarus mailing list