Re: coding style

"h.g. muller" <[email protected]>
Newsgroups gmane.comp.gnu.xboard.devel
Message-ID <[email protected]>
>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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.