Mat Scales wrote: > Gavin Vess wrote: >> .. although the Linux Kernel team does not use braces when there is >> only one statement after the conditional. I would prefer we follow >> this standard more closely, and eliminate braces around a single >> statement. Anyone else have this preference? > Have you really never seen someone introduce a bug into a system because > they added another statement to the conditional and forgot to put the > braces back in? These things don't happen every day, but they are > relatively common and can be difficult to spot. Always having braces in > place eliminates a source of bugs and not doing it doesn't save much, so > for me the choice is easy.
Please pardon the "me too" post, but this has been my experience as well, and yet more so with loop constructs. I don't see any real advantage to losing braces on "if" statements, and then we ride the slippery slope onto losing braces on one-liner "while", "do-while", "for", and "foreach". I believe that it is best practice to have the braces, even when not technically necessary, for clarity and elimination of a common entry vector for bugs. Best regards, Darby
