This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Excessive use of parenthesis

When writing C, we've all heard people say "it doesn't hurt to use extra parenthesis" or "if in doubt, enclose it in parenthesis".

Now, while both of these statements are basically correct in their applicable context, I personally feel that excessive use of parenthesis (especially where they're not needed) is indicative of an author who is uncertain of operator precedence, and frankly it drives me nuts.

Personally, I place more importance on understanding and knowing operator precedence (even if it means keeping a little cheat-sheet pinned on your office wall) than on "feeling secure" by flooding/obscuring the code with just-in-case parenthesis.

Am I being fussy?

Parents
  • There is, of course, the alternate argument that, if you need to be adding parentheseses, your expression is too complicated anyway!
    You should just break the expression into simpler steps, using intermediate variables if necessary (this shouldn't inflate the code using a modern optimising compiler...)

Reply
  • There is, of course, the alternate argument that, if you need to be adding parentheseses, your expression is too complicated anyway!
    You should just break the expression into simpler steps, using intermediate variables if necessary (this shouldn't inflate the code using a modern optimising compiler...)

Children