[haiku-development] Re: Clarifying multi-line if-clause rule

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 7 Feb 2011 19:16:54 -0500

>
> This next thing is undoubtly considered a multi-line if-block:
>
>  if (some condition) {
>    // Comment on the non-obvious
>    do_something();
> }
>

This is not a multi-line if statement and therefore it does not require
braces. Whether braces should be added for style reasons is debatable.


>
> The question is with this one:
>
> if (some condition which does not fit in one line
>    && extends to the next line) {
>    do_something();
> }
>
> if (some condition which does not fit in one line
>    && extends to the next line)
>    do_something();
>

This is also not a multi-line if statement and therefore does not require
braces. Again, style is debatable.

I think the easiest solution is just to always require braces for all if
statements, that way the rule is simple and there are no exceptions.
Otherwise debates like this will pop up.

John Scipione

Other related posts: