Re: braces needed?

From: lilburne (lilburne_at_godzilla.net)
Date: 01/31/04


Date: Sat, 31 Jan 2004 21:14:42 +0000

Jonathan Turkanis wrote:

> "Jack Klein" <jackklein@spamcop.net> wrote in message:
>
>>
>>There is just too much chance for error, not only when writing the
>>original code, but even more so later when the code is modified for
>>defect fixing or upgrade.
>>
>
>
> Certainly requiring braces seems to have wide acceptance, but your
> statement is an exaggeration. Glancing quickly through the standard,
> the Dinkumware standard library which ships with VC7.1, and the Boost
> source, I find numerous uses of 'if' without braces. Generally the
> meaning of such code is immediately clear.
>

Perhaps they don't have coding standards, or neglect them
from time to time. Our coding standard requires braces
around all control statements and even 'outlaws' single line
  variants:

    if (a < b) function();
    for (int x = 0; x < y; ++x) function();

yet from time to time you'll find such examples in the
codebase even written by the originators of the standard.
They get to fix it.



Relevant Pages

  • Re: WM_NCHITTEST
    ... a "standard" window. ... original code from Karl Peterson's site.) ... It seems that once one starts to customize the GUI it's ... particular area of the NC area in question (HTCAPTION, HTCLIENT, HTCLOSE, ...
    (microsoft.public.vb.general.discussion)
  • Re: Portability VMS to Linux
    ... You have to recode it because the original code was written with ... compiler-specific extensions instead of in standard Fortran. ... tended to be pretty good about identifying nonstandard features, ... multitude of different Fortran compilers for Linux. ...
    (comp.lang.fortran)
  • Re: code optimization- Removing if .. else conditions in for loops
    ... For most compilers the two are exactly the same. ... Unfortunately the ANSI C standard is basically broken on the right ...
    (comp.lang.c)
  • Re: Member template instantiation confusion
    ... > ...Perhaps you'll see why your original code didn't work. ... places in the standard that explain this? ... Rick ... (reply address is bogus) ...
    (alt.comp.lang.learn.c-cpp)
  • Re: braces needed?
    ... >> have any measure of control over the coding standard. ... > Certainly requiring braces seems to have wide acceptance, ...
    (comp.lang.cpp)