Re: C question for you old guys ;-)
Re: C question for you old guys ;-)
- Subject: Re: C question for you old guys ;-)
- From: Greg Weston <email@hidden>
- Date: Mon, 9 Jun 2003 02:13:44 -0400
On Monday, June 9, 2003, at 01:00 AM, Daryn wrote:
I've made it a habit ( "coding standard", if you will) to always use
{} for if, while, for, etc.
I'll second Marcel's implied recommendation. In fact, I _did_ make it
a
standard in my shop. It's good to be the chief. Or at least the
shaman.
While I agree, the recommendation is a non sequitur.
Not really. It's about habits. Or conditioning if you prefer the more
sinister term. The problem, AFAICT, seems to arise because this:
while(blah());
is perfectly valid and reasonable. The idea behind standardizing on
_always_ having a block is that while the above code is syntactically
legal, it's not acceptable and shouldn't make it through any kind of
code review process. You could even automate a check for that
structure. It _should_ read (in a pedantic world) something like this:
while(blah())
{
/* This space intentionally left blank. */
}
(Feel free to prefer the opening brace on the prior line.) It's easier
to read, easier to add or remove code to the conditionalized block, and
empirically lower risk of stray semicolons.
G
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.