On 2011-02-08 at 10:07:56 [+0100], Oliver Tappe <zooey@xxxxxxxxxxxxxxx> wrote: > On 2011-02-07 at 23:06:50 [+0100], Stephan Assmus <superstippi@xxxxxx> > wrote: > [ ... ] > > > > 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(); > > Am I right in assuming that this would apply to multi-line while- and for- > conditions, too? Yep. > From my POV, if readability is the goal, I'd go with the brace style we use > for 'case' already: > > if (some condition which does not fit in one line > && extends to the next line) > { > do_something(); > } That's indeed the easiest to read. That downside is that, since, for consistency, one would that style also in case of single-line conditions and "else" blocks, it's using up quite a bit more space. Which IMO decreases readability again, as less can be displayed in a window at once. Besides I'd be strictly against such a drastic change at this point. Regarding "case", that's a different case, since the braces don't have to do anything with the label. One could put the block anywhere as long as it fits the variable scoping needs. > From the other two, I agree that the variant with braces is slightly easier > to read, but so far I have never come across a coding style that required > braces for multi-line conditions (never mind where the braces go). > > So I guess if we require braces for multi-line conditions, we should expect > that new devs will find that rule a bit peculiar/awkward. > > But readability has to be weighed against consistency of our coding style > and > I wouldn't want to introduce variations for each and every statement kind > just because it reads slighty better in a particular case. > Since every new dev has to memorize the specialties of our style, I think > it'd be wise to only introduce special rules for stuff we can't really live > without. > > I could live without a special rule for multi-line conditions, so I suggest > to stick with using braces only for multiple-line blocks following a > condition. We'd need to clarify that in our styleguide, too. Well, "use braces in all cases but trivial, non-wrapped if/else/while/do/for statements" is at least as simple a rule. CU, Ingo