Article View: comp.lang.c
Article #1404Re: does an expression in a logical statement need parenthesis for proper evaluation?
From: David Brown
Date: Tue, 10 Nov 2026 07:36
Date: Tue, 10 Nov 2026 07:36
42 lines
3327 bytes
3327 bytes
On 10/11/2026 01:54, Keith Thompson wrote: > 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. Speaking as someone who uses the bit operations more than most programmers, I can't tell you that either - I use parentheses to make it clear. I have other things on which to use my limited brainpower! There are things that it is perhaps better not to know - because then you write your code in a clearer fashion that is obvious to experts and newcomers alike. (I am not necessarily talking about newcomers to C or C++ - people work with these languages in wildly different fields, and work on wildly different types of code and styles of coding.) > > Preferences for *how many* strictly semantically unnecessary > parentheses are appropriate vary greatly, but few C programmers > would insist on none. >
Technical Details
Message-ID:
<11cuhh2$1ujot$1@dont-email.me>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!.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> <11ctq02$1ohj1$1@kst.eternal-september.org>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!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: does an expression in a logical statement need parenthesis for proper evaluation? Date: Tue, 10 Nov 2026 08:36:02 +0100 Organization: A noiseless patient Spider Lines: 42 Message-ID: <11cuhh2$1ujot$1@dont-email.me> 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> <11ctq02$1ohj1$1@kst.eternal-september.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 10 Nov 2026 07:36:03 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2051869"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FIrTlEM/1MMycIfeoRtsav1AR2A+9Qts="; posting-host="a907b94bf0fcbfeffbc81a62ebe9823d" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:3c/9ybEZaqoShW9rp/F7hqUTJEQ= sha256:X2zcEoKjfSpSqUDBCbFT+5gFlyktYYX6Zw5bzjM6CI0= sha1:7jM7fzwTdWOL9YZc9DG1e9dK2Zc= sha256:EKDCzl/oHyC/wwFeFnU7b5JrT6271qsAEHFkEU6Drl0= Content-Language: en-GB In-Reply-To: <11ctq02$1ohj1$1@kst.eternal-september.org>