Article View: comp.lang.c++
Article #805Re: does an expression in a logical statement need parenthesis for proper evaluation?
From: Keith Thompson
Date: Tue, 10 Nov 2026 00:54
Date: Tue, 10 Nov 2026 00:54
30 lines
2694 bytes
2694 bytes
Lawrence D’Oliveiro <ldo@nz.invalid> writes:
> On Mon, 9 Nov 2026 06:00:40 -0500, James Kuyper wrote:
>> I tend not to use unnecessary parentheses, and I know the grammar
>> well enough to correctly identify them - but many people don't know
>> the grammar that well, which might include the next person to
>> maintain my code.
>
> Even if they haven’t committed the precedence table to memory, surely
> they have the ability to look things up online
> <https://en.cppreference.com/c/language/operator_precedence>.
>
> If someone has regular trouble with certain language features, why
> aren’t pages that clarify those very issues not already in their
> browser bookmarks?
If I haven't memorized all the precedence levels, I greatly prefer
an expression I can read at a glance to one that requires me to
consult some document before I can be sure what it means, just so
I can continue to the next line of code.
Just one example: I couldn't tell you whether `^` or `|` binds more
tightly without looking it up. If you can, that's great.
Preferences for *how many* strictly semantically unnecessary
parentheses are appropriate vary greatly, but few C programmers
would insist on none.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Technical Details
Message-ID:
<11ctq02$1ohj1$1@kst.eternal-september.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mailReferences:
<11cj4a0$23796$1@dont-email.me> <11crsub$11ikc$1@dont-email.me> <11cs94q$15ptp$1@dont-email.me> <11cti69$1lilf$5@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: does an expression in a logical statement need parenthesis for proper evaluation? Date: Mon, 09 Nov 2026 16:54:19 -0800 Organization: None to speak of Lines: 30 Message-ID: <11ctq02$1ohj1$1@kst.eternal-september.org> References: <11cj4a0$23796$1@dont-email.me> <11crsub$11ikc$1@dont-email.me> <11cs94q$15ptp$1@dont-email.me> <11cti69$1lilf$5@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 10 Nov 2026 00:54:26 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="1853025"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZCUIaTLYV/o9fnAgp1mml"; posting-host="1913f26eee512bea2f43149dcf67b413" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:NKE8d3FdxtaqpuUxRurV8+B56RI= sha256:Xtad+gykdPmQ/Jhiq76DCZYfiQjxpaT9WVcwaQQhvPw= sha1:Eoaua8qgSa+KkfJKN9uUmwaxKlM= sha256:cCWllj1QS4uQP9E6uU3SVbxYtIccY7A1dteTzCJZTZY=