In the past, including the very recent past, I have always used brackets for my C "if-else" conditions, even if there was only a single line within the if clause.
I've had a change of heart. This morning. At 10:12 am to be precise. Suddenly, it just started to annoy the crap out of me. I realize I have to pay a little extra attention to detail by omitting the brackets, but I suddenly like the 'no-bracket' style better.
/me shrugs
Re:ICKY POO POO
djberg96 on 2004-11-11T18:57:08
Heh. Well, the functions where I'm doing this are generally short. For larger functions I'd probably be more inclined to keep the brackets.The main problem I have with people using this style is that they don't indent or space worth a darn. That can get real confusing, real quick. That's probably another reason I've avoided it in the past.
Re:ICKY POO POO
spur on 2004-11-12T07:36:42
Just because a feature can be misused - doesn't mean it should be misused (we Perl hackers know it best of all...). The "no bracket" single statement "if" is in C for a reason - and AFAIK it is considered good style to use it. With proper indentation, the problems you may run into become blazingly obvious. In 6 years of C experience, I've never had a bug resulting from this feature.
Some day you'll be skimming code that's passed through the fingers of someone who had their tabs set to an unusual number of spaces, and something like
will go flying by. Are you sure you'll read it correctly?if (somecondition)
printf("Whatever\n");
dosomethingelse();
Re:Confounded by tabs
djberg96 on 2004-11-12T21:56:45
I have learned to always set the "tabs to spaces" option in whatever editor I'm using.:)