vade retro Pascal - redundant parentheses revisited
wijnen at debian.org
Fri Oct 25 10:21:18 EDT 2013
> On Tuesday 22. October 2013 18.01.10 Werner Almesberger wrote:
> > [ Came across a security-related article that made me think of an
> > old and constant gripe of mine. Here's my rant, somewhat off-topic. ]
On Tue, Oct 22, 2013 at 07:11:56PM +0200, Paul Boddie wrote:
> For example:
> good_to_go = (a > 10) || (a == 0);
You realize you're doing exactly what Werner just told you not to do,
> There is also Rule 12.5, that applies specifically to logical operators.
> It says, that the operands of logical && or || shall be primary
> expressions. There is an exception that if there is a sequence of
> only logical && of only logical ||, then extra parentheses are not
I really dislike that. In logics, "or" is written as addition and "and"
as multiplication (and that mostly makes sense, too, if you consider
booleans as 1-bit integers). Being used to that, there is no confusion
at all about the precedence; of course multiplication comes before
addition. I am slightly annoyed by the compiler warnings telling me to
add parentheses to those expression when IMO there's nothing unclear
Now that I read Werner's post, I'm even more convinced that they not
only serve no purpose, but are actually harmful.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: Digital signature
More information about the discussion