[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XBoard-devel] coding style
From: |
h.g. muller |
Subject: |
Re: [XBoard-devel] coding style |
Date: |
Tue, 03 Jan 2012 13:26:17 +0100 |
int
MyFunc (char a, char b, int c)
I used to intensely dislike that newline, because it makes it impossible
with most editors to find the declartion imediately by searching for
type + function name. But perhaps this is what the space is supposed
to solve.
else
{
while (z)
{
haha += foo (z, z);
z--;
}
return ++x + bar ();
}
Currently the style that is most consistently used would be:
else {
while (z) {
haha += foo (z, z);
z--;
}
return ++x + bar ();
}
Actually I think this is much better, as the other one wastes a lotof extra
lines,
strogly degradig the readability of the code by reducing the number of lines
in view. Many if statements have just one or two statements in if-clauses,
Compared to
if(A) B;
the style
if(A)
{
B;
}
wastes 300% space. For else-less ifs with a short if-clause, I think the
simple one-liner if(A) B; is much preferable.
It is usually possible to eliminate braces by clever use of commas, though.
If I knew that braces took two extra lines, I would definitely write
if(x>y)
h = y, y = x, x = h;
rather than waste vertical space on the braces.