On 9 Jan 2001, Lars Gullik Bjønnes wrote:
> I will remove () that has no value when I see them.
>
> - two points:
> - () without meaning kindo shows that the coder does not know the
> precedence rules
I'm sure you don't know all of them well enough to securely disambiguify
any given C++ expression I might throw at you.
> - () without meaning makes the code harder to understand
Look deep into your heart. You know there is meaning to the
"superfluous" parenthesis, and Juergen is not using too many
parentheses. He might be making lots of other bug^t^t^tfeatures, but don't
attack him for being trigger happy with the curves.
> - () mithout meaning hides () that are really needed.
Parenthesis are needed if the author feels they are needed. And then, they
are really needed. It's as simply as that.
Come on, Lars. Code is for communication between humans, not machines.
That's why we don't use binary codes.
You should write the code such that humans can understand it,
and that involves proactively using parenthesis when there is
some doubt to the meaning, or you generally feel that it can improve the
understanding.
I know the precendence rules for C++ about 90%, and others know them
80%. You might know them 95%, but the thing is that the common ground for
all of us might be as low as 70%. (Actually I expect it to be lower.)
Therefore, it is a good idea to use parenthesis when you feel that it can
increase the communication between *humans*. (That includes communicating
with yourself.)
On top of this, add the fact that different programming languages have
different precedence rules. There is no *natural right way* to
unambiguously define the precendence rules globally once and for all for
all operators.
Therefore, we should not let our communication be ruled by the whims of
one particular language designer. His decision is not the best, or
the only one. (This is particularly so in the case of C++, for which the
precedence rules completely suck.)
So when you say that you want to undiscriminatingly remove the
"redundant" parentheses, you might at best be targeting the communication
to you only. Maybe it's better to ensure the communication with the rest
of the team?
I'm sure Juergen's code is not as convulted that you can't understand what
is going on, even with a few parenthesis where you feel they are redudant.
Greets,
Asger