On 1/19/07, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
On 1/19/07, James Rosten <seinfeld90@gmail.com> wrote:
Just how lenient are you on the spaces in conditionals and loops thing :P ? Like: for ( int i = 0; i; ++i ) {
I haven't figured that one out in the scope of this codebase, so we'd have to ask judd about that. Personally, I prefer no spaces between the token and opening paren, and spaces after each ; and between operators:
for(int i = 0; i && i < 4; ++i)
Coding style for a project is not necessarily any one person's _preferred_ style, but just something that was agreed upon by all. I prefer spacing things out more, but consistency is a heck of a lot more important in my mind in making code readable. I think what Aaron just outlined fits perfectly with the preexisting code base in pacman.
But that's just my preference. I also prefer to align args oddly in the case of newlines:
if(x == 4 && y == 7 && z > 23) {
But again, there's no concise "ruling" on that, so I say do what feels best.
I would say this is a good guideline to follow, and one places where spaces should be used for (and I hate to use this word) 'indentation'. As long as you don't set in your mind that tab = indent, this concept makes sense. Example of the code above, if it was in a block and indented slightly: <code leading into this> <tab>if(x == 4 <tab><3 spaces>&& y == 7 <tab><3 spaces>&& z > 23) { Doing it this way serves a simple purpose- although modelines exist in the file, if these were ever changed, the code would still "look right". The tab is used for block indents, and the spaces are used to offset the width of the "if(". I hope I'm not way off-base with this. -Dan