xboard-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XBoard-devel] coding style


From: Arun Persaud
Subject: Re: [XBoard-devel] coding style
Date: Tue, 03 Jan 2012 11:25:56 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0

Hi

> 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.

really? I would think that most editors used for programming would be
able to search for "^funcname" and should be able to find it easier,
since that should be the only place where the function name is at the
beginning of the line.
If your editor can't search for regexp than I guess the space can indeed
help.

So is everyone ok with using

int
funcname (int a, int b)

for functions? If so, I can change all files to this new format over the
next days...

>> 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.

Guess this is a matter of taste... to me having those extra lines makes
it a lot more readable than the other version... mostly because I find
it easier to see where the block starts and ends by having the {} in the
same column...

> Many if statements have just one or two statements in if-clauses,
> Compared to
> 
> if(A) B;
> 
> the style
> 
> if(A)
>   {
>     B;
>   }

ah, but the last lines you mention is not what the coding standard uses,
it would be

if (A)
  B;

which seems reasonable to me.

> 
> 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.

for a swap this would perhaps make sense, but if the lines where not
related, I wouldn't want to have them in the same line...

cheers
        ARUN




reply via email to

[Prev in Thread] Current Thread [Next in Thread]