Hacker News new | past | comments | ask | show | jobs | submit login

Without curly braces it is simpler to mess up if you revisit the code, maybe especially adding ambiguous else conditions.

I'm sure you and the GP would never forget to add curly braces when inserting an else, but the junior developer who comes afterwards might, and it's just not a huge deal to have the braces because it's two extra chars.

Quite frankly the Linux kernel coding style is wrong on this one in general, I guess we can assume they are experienced enough to put braces in when adding an else clause and so it's not going to cause them errors. But with junior devs it certainly could.




I definitely don't agree with everything in that style guide either, but I can respect it. I think what I like the most is that it's non-judgmental (or when it is judgmental it is clearly sarcasm). It has nice blurbs like "Please at least consider the points made here." - which is the right attitude for a style guide.


If you are worried about else conditions, wouldn't this be the way around it?

{if (condition) singleFunctionCall();}


Why is this being downvoted? How do curly braces around the function call help with ambiguous else branches?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: