In message <[email protected]>, Alf P. Steinbach
wrote:
> This is just unsubstantiated opinion, but worse, it makes a tacit
> assumption that there is "best" way to do indentation. However, most
> programmers fall into that trap, and I've done it myself.
Having used so many different languages over the years, I have settled on a
reasonably common set of indentation conventions that work across most of
them.
The only one that currently annoys me is JavaScript, because its semicolons-
are-optional rule means that certain ways I write statements continued
across multiple lines are interpreted as prematurely completing the
statement.
In revenge for that, I refuse to put optional semicolons in my JavaScript
code altogether.
> I may or may not have been responsible for the similarly impractical
> compromise convention of using three spaces per indentation level. At
> least, in one big meeting the question about number of spaces was raised
> by the speaker, and I replied from the benches, just in jest, "three!".
> And that was it (perhaps).
I use four. Why four? Because it’s divisible by two. Because I use the half-
step (two columns) for lines containing nothing but bracketing symbols:
for (i = 99; i > 0; --i)
{
printf("%d slabs of spam in my mail!\n", i);
printf("%d slabs of spam,\n", i);
printf("Send one to abuse and Just Hit Delete,\n");
printf("%d slabs of spam in my mail!\n\n", i - 1);
} /*for*/
for i := 99 downto 1 do
begin
writeln(i, " slabs of spam in my mail!");
writeln(i, " slabs of spam,");
writeln("Send one to abuse and Just Hit Delete,");
writeln(i - 1, " slabs of spam in my mail!\n\n")
end {for}
Actually this looks like another opportunity for a loop-with-exit-in-the-
middle:
for (i = 99;;)
{
printf("%d slabs of spam in my mail!\n", i);
printf("%d slabs of spam,\n", i);
printf("Send one to abuse and Just Hit Delete,\n");
--i;
if (i == 0)
break;
printf("%d slabs of spam in my mail!\n\n", i);
} /*for*/
--
http://mail.python.org/mailman/listinfo/python-list