One of the reasons for success of Python is its code formatting/indentation.
You may be right but, personally, I doubt it.
I find that Pascal formatting, though very clear, can be further simplified to Python-type formatting.
When I find code formatted in the "python way" you suggested, the first thing I do is reformat it to make its logical blocks more evident.
I'd format the snippet of code you presented as follows:
with TBarSeries(Result) do
begin
BarBrush.Color := AColor;
BarPen.Color := AColor;
BarWidthStyle := bwPercentMin;
if APlotType = ptBars then
begin
AxisIndexX := AChart.LeftAxis.Index;
AxisIndexY := AChart.BottomAxis.Index;
end
else
begin
AxisIndexX := AChart.BottomAxis.Index;
AxisIndexY := AChart.LeftAxis.Index;
end;
end;
A begin/end denotes a compound statement that is controlled by its "owner" (in your example, the "with" and the "ifs".) Since compound statements are surrogates to their owner, they (IMO) should be at the same level of indentation since they are logically at the same level.
The modified version results in less lines (separate line for begin is avoided) and less indentation (indentation for begin and end are avoided) so that 3 statement blocks are seen clearly.
A separate line for "begin", not only should _not_ be avoided, it should be required because it marks the beginning of a block which should be aligned with the keyword that marks its end (in this case "end".)
One of the things I find most annoying in C code are "definitions" that go like this:
struct astruct {
SOMETYPE somefieldname;
int someotherfieldname;
}
For trivial definitions it's easy to "see" that it's one block but, when the data type has many other structured types in it, matching the "{" to the "}" is a pain, particularly when you have to add a new struct or field somewhere in there. Another thing that makes the entire thing look like a blob of text is the total lack of alignment of types and variable/field names. A large and complex structure defined like that is "binary roadkill". Fortunately, most C programmers figured out that indenting the definitions a couple of spaces makes it easier to read. In a few centuries, evolution willing, they might start formatting code halfway decently. Evolution is really a great thing, too bad it's so slow.
I am interested in views of other users on this forum.
Good indentation can make a program much easier to read and understand.