Fanning the Code Convention Flames: Parens After Keywords


Much like the famed spaces vs tabs, there are differing preferences about whether to put a space between a keyword and any following parenthesis:

if(condition)... //vs if (condition)...

I submit that including the space is a stupid convention unless you also handle functions the same way:

void foo (int a) {} foo (4);

Which, of course, is rarely ever done, even in codebases that always put spaces after keywords like if.

3 comments for "Fanning the Code Convention Flames: Parens After Keywords"

  1. (Guest) Bernard
    2013-08-20 04:53

    Nonsense. Functions aren't statements.

  2. 2013-08-20 13:29

    The distinction isn't so clear. For example, many languages consider a lone function call (such as the "foo ();" above to count as a statement. In the C-family, nearly any of the constructs that are terminated by a semicolon are considered statements (with declarations being a grey-area). And there are languages (Haxe and Nemerle, for example) which consider things like "if", "switch", etc to be expressions, which puts them fully in the same syntactic group as function calls.

    Additionally, the topic here is stylistic consistency, and that doesn't necessarily require that any distinction between function and statement actually be relevant at all.

  3. (Guest) Bernard
    2013-08-20 17:59

    Sure, but a function call is an identifier followed by parens, and the others are keywords followed by the same. Different enough in my head for the 'inconsistency' to not bother me.

Leave a comment

Captcha