Thread:Manual talk:Coding conventions/JavaScript/Whitespace conventions for control structures should match those for PHP/reply (2)

One could simply turn around your use cases if one would say that we are talking about spaces before parentheses rather than spaces after keywords, and perhaps that's actually the logical ting to do:


 * 1) Consistency in style (sometimes a space before parentheses and sometimes not is inconsistent, e.g.   is very inconsistent with  ).
 * 2) Consistency in syntax (some operators require it, some operators don't) - Sorry, but I don't understand. I am not sure whether all keywords are operators, but not all operators are keywords. So we are not consistent here at all right now. E.g.   rather than   or   instead of.
 * 3) Simplicity in distinguishing operators/keywords from function invocations. So, that one is a contradiction to #1 now. But it's also not needed since you still have several indicators making clear whether the thing, preceding parentheses, is a keyword or a function-call:
 * Your IDEs syntax highlighting (come on, probably all serious IDEs have this, even most modern debuggers do)
 * Your knowledge (and yes, you understood me right when I said "know your keywords" :)
 * Keywords followed by parantheses " " (control structures) will always be followed by braces " " as well (per our own conventions where we don't allow Braceless control structures).
 * Function calls should be followed by ";", control structures don't require this. The only exception here would be something like . This function example is actually also the only case where a keyword followed by parantheses, followed by braces, doesn't necessarily have subsequent, indented line.

I guess there could evolve a huge discussion around this and I am sure you are convinced that the current style is the one to go, I am convinced that this is the style which makes a lot more sense. For me the current style is just as inconsistent as the one I'd suggest is for you. There must have been a similar discussion when people decided over spacey or not so spacey style in PHP and perhaps we should learn from history and be consistent with PHP - it still is MW code and both languages have C-like syntax, so why not leave this rule to the common coding conventions. I believe the more rules are described on a common basis, the better. It makes things simpler and lets you concentrate on the essential things like actually writing code and getting stuff done rather than studying conventions for different syntactically very similar languages.