5 ms·
I find that many people really dislike to put what they feel are “extra” braces.
by saagarjha 7y ago
I find that many people really dislike to put what they feel are “extra” braces.
- Xelbair 7y agoand then it bites them in the ass when they need to add another line later on.
- buckminster 7y agoI've been writing C and C++ for thirty years and I've made many mistakes but never that one. I suspect it's far more common if an always-uses-braces programmer edits an optional-braces code base. I'm not religious about it though. If the Romans are wearing braces I'll wear braces.
- mannykannot 7y agoGetting worked up over a non-issue is counter-productive (to be clear: it is fussing over the 'extra' braces that is the non-issue; having an explicit syntax for the empty statement is an issue, and one that makes sense.)
- kevin_thibedeau 7y agoThey are extra braces. The C grammar allows any statement as the body of a control structure. Compound statements are only one of the possibilities. Just because other C-like langs have different grammar requiring the braces doesn't mean C has to look like them too.
- WalterBright 7y agoJust to be clear, D doesn't require extra braces. It just doesn't allow an empty statement terminated with a ;. if (x) foo(); // accepted if (x) ; // rejected if (x) { } // accepted