Le 29/08/2011 12:28, Eric Wetzel a écrit :
For the record, here are the relevant standards:
GNU: http://www.gnu.org/prep/standards/standards.html#Writing-C
Kernighan&  Ritchie:
http://en.wikipedia.org/wiki/Indent_style#K.26R_style (sorry, didn't
try very hard on this one)
Linux: http://www.kernel.org/doc/Documentation/CodingStyle


I strongly disagree on using anything that resembles K&R.
Where I work you could get reprimanded and maybe even fired if you did use it.

for example something like this is not only unacceptable, you will get a 
reprimand.

if (x == y)
    x++;
else
   x--;

this is also unacceptable

if (x == y) {
    x++;
}
else {
  x--;
}

This must be used even if there is only one line of code. Unless you're 
compiling with a TRS-80 you shouldn't be concerned about the added time for 
compiling.

if (x == y)
{
     x++;
}
else
{
    x--;
}

The reason is for clarity. It is true that the code is easier to follow this 
way.
When I take code from open source and want to go thru to understand it,  I often 
have to load the file in slickedit and do a beautify to make the code more readable 
as it is often stuck in that old K&R coding style which I cannot stand.


Since we have bigger monitor than in the 70s and 80s why make the code 
unreadable?
The only valid reason for using K&R would be
1- You still expect to be stuck with a teletype at times and want to make sure 
you can see many lines of code at once
2- You can't get yourself to replace your VIC-20 or TRS-80.
3- You are still stuck with a tiny 13 inches or smaller screen.

Michel

--
Tired of Microsoft's rebootive multitasking?
then it's time to upgrade to Linux.
http://home.comcast.net/~mcatudal

_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to