it's not like a glaring mistake |
Isn't it? (seeing the 90 and 10, the first thing I did is check the termination condition and increment)
I do think it would have been clearer if it had been written as:
for(x=10; x >= +90; x-=10)
rather than
for(x=10;x>=+90;x-=10)
(A chance to take one of my hobby horses for a ride!? Now, not not everyone would agree, but I believe that...)
Source code should generally use white space in a similar way to prose. Horizontal space to separate the meaningful pieces of a line, similar to words. (There is some scope for different takes on what these pieces are.)
And vertical space to separate groups of lines of code, like paragraphs. (Not just to separate functions.)
I would go one futher and write it as;
for (x = 10; x >= +90; x -= 10)
But there are other variant
1 2 3
|
for( x=10; x >= +90; x-=10 )
for (x = 10; x >= +90; x -= 10)
// etc
|
Everywhere I've worked the coding guidelines have mandated this kind of space to make it easier to see that's going on, esp. around operators.
One popular standard is Google's. I don't agree with all its points, but when you're working with other people, a consistent code layout is beneficial. In the absence of anything else, it is a good starting point.
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Horizontal_Whitespace#Horizontal_Whitespace
And I quite like this guy's take:
Statement Formatting
http://www.oualline.com/style/c04.html
Andy
PS I would be interested to see a coding standard that mandate the use of no space around binary operators, so if you know of one, please paste the link here.