tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: style change: explicitly permit braces for single statements
> Personally I don't think there's any good excuse for not always
> putting braces around all single-statement blocks.
Well, you may not think it good, but I prefer
if (x < 0) return(n);
to
if (x < 0) { return(n); }
. I find the braces pure visual clutter in the latter.
I also prefer
if (compute_length(end1->vtx->pt,end2->vtx->pt) < delta)
return(scale(normal,size));
to
if (compute_length(end1->vtx->pt,end2->vtx->pt) < delta)
{ return(scale(normal,size));
}
because of the vertical space saved, but I usually actually write the
latter because of software limitations - figuring out how much to
indent the second line is complicated, requiring something like a
codewalker to tell whether the second line is the consequent of the if
or a continuation of the condition. (And I prefer either of them over
if (compute_length(end1->vtx->pt,end2->vtx->pt) < delta) {
return(scale(normal,size));
}
but that's a holy war for another day.)
Ultimately, it comes down to: I prefer readbility - which is mostly an
aesthetic judgement - over strict conformance to rules. I consider
such `rules' as being there to serve, not to constrain; I think
"recommendations" would be a better word. I've yet to see a style
"rule" - my own or anyone else's - that doesn't impair readability at
least occasionally.
> [I]n my opinion C is just not really safe without [the braces].
Is C *ever* safe? (Safe from what?)
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index