xboard-devel
[Top][All Lists]
Advanced

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

Re: [XBoard-devel] coding style


From: Byrial Jensen
Subject: Re: [XBoard-devel] coding style
Date: Tue, 03 Jan 2012 23:21:52 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111109 Thunderbird/3.1.16

Den 03-01-2012 20:25, Arun Persaud skrev:
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...

Indeed. The GNU coding standings says in section 3.4:
"However, it is easy to support pre-standard compilers in most programs, so if you know how to do that, feel free. If a program you are maintaining has such support, you should try to keep it working."

You could argue that xboard is trying to support pre-standard compilers, but that support is already broken. So I find it futile to try and keep it, especially if no developer can even test it.

But if you are going to change everywhere, it would best if HGM pushed all his bugfixes etc. first. BTW they should be pushed anyway.

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

I too prefer the extra lines.

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

If the intention is the swap and h is not used again, then it can done much elegant with a macro, for instance with:

if (x > y)
  SWAP(x, y, int);

where SWAP is defined in some header file as

#define SWAP(x, y, the_type) \
do {\
  the_type temp = y;\
  y = x;\
  x = temp;\
} while(0)\



reply via email to

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