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



paul%whooppee.com@localhost (Paul Goyette) writes:

>Another +1 here.  The "add another statement" is frequently "add a
>debug_printf()" and many is the time i've broken an if statement by
>adding debug code.

{ debug_printf();
}

works and doesn't get forgotten before committing.

I personally find redundant braces or parentheses distracting,
which is mostly due to what idioms you are used to read and write.
Changing that definitely doesn't help with code quality.

And the goto_fail bug prevention is a myth. You can create such
kind of errors with and without braces. Even the Wikipedia case
that is used as proof is bogus since it doesn't make the bug (the
second goto) detectable by the compiler.

N.B. if you want to check intent, you'd need an assertion that the
failure path returns an error code and not zero and probably a
language that tags success and error paths differently or uses
exceptions instead of error paths which have their very own problems.

-- 
-- 
                                Michael van Elst
Internet: mlelstv%serpens.de@localhost
                                "A potential Snark may lurk in every tree."


Home | Main Index | Thread Index | Old Index