vade retro Pascal - redundant parentheses revisited

Bas Wijnen 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,
right? ;-)

> 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
> required.

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
abou them.

Now that I read Werner's post, I'm even more convinced that they not
only serve no purpose, but are actually harmful.

Thanks,
Bas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.en.qi-hardware.com/pipermail/discussion/attachments/20131025/4d507204/attachment.pgp>


More information about the discussion mailing list


interactive