[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Operator precedence and code readability
- From: Foster Schucker <Foster@...>
- Date: Sat, 09 Jan 2021 09:12:34 -0500
You can always follow the rule:
When confused and in doubt,
Use parentheses all about.
(Taken from Robert Heinlein's
"When in trouble and in doubt,
Run in circles, scream and shout" )
I got taught "Please Excuse My Dear Aunt Sally". Paren, exponent,
multiply, divide, addition subtraction, so that is easy,
If it's code for just me, then parens when needed, if I'm teaching
beginning programmers or someone else may read what I wrote, then all
the parens needed to make it clear the order I/they were thinking.
Taking seconds to add extra parens to save hours is a pretty simple choice.
Foster