Mail Archives: djgpp/1997/10/09/13:00:07
Ed Beroset wrote:
> > - and in fact violates the coding standards of the last
> > three places I worked at. 8-)
>
> How very odd. Do those coding standards state something like, "all
> while statements shall have curly braces" or do they have some specific
> prohibition against the "continue" keyword?
Not at all odd. Most coding standards I've seen insist on braces
on all controlled statements - if, while, do, for, etc. Particularly
when developing code it avoids problems when inserting statements.
For instance:
Original code:
if (x < y)
x = y;
Then you realise you want to do something as well. It's very easy
to end up with something like:
if (x < y)
x = y;
a[x] = y*y;
and not notice that the second statement isn't actually controlled
by the if. It's even worse if you're used to seeing K&R type
braces like
if (x < y) {
x = y;
a[x] = y*y;
}
It also minimises the risk of doing something else wrong while
editing - you can delete a statement without having to delete the
braces as well (and seveal times I've deleted one line too many).
(Auto-indenters don't help when it's C++ instead of C, they break.
Unless the GNU people have upgraded indent recently, but from what
I heard they weren't interested because the 'official' language
of GNU is C.)
Chris C
- Raw text -