Article View: comp.lang.c++
Article #807Re: does an expression in a logical statement need parenthesis for proper evaluation?
From: Lynn McGuire
Date: Tue, 10 Nov 2026 04:39
Date: Tue, 10 Nov 2026 04:39
40 lines
3246 bytes
3246 bytes
On 11/9/2026 6:54 PM, 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. > > Preferences for *how many* strictly semantically unnecessary > parentheses are appropriate vary greatly, but few C programmers > would insist on none. I ship my software written in four different software languages. C++, Fortran, Visual Basic, and C#. Remembering the nuances of each is tricky. I find it best to be safe. I have shipped software in about a dozen software languages in my 51 year career. C++, Fortran IV (66), Fortran 77, Visual Basic, C#, Turbo Pascal, Basic, Turbo C, Unix C, IBM 370 Assembler, Intel x86 Assembler, AWK. I think that I am leaving out a couple that I cannot remember at the moment. Lynn
Technical Details
Message-ID:
<11cu75a$1s1rc$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: Lynn McGuire <lynnmcguire5@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, 9 Nov 2026 22:39:04 -0600 Organization: A noiseless patient Spider Lines: 40 Message-ID: <11cu75a$1s1rc$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 04:39:07 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1967980"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iMXkbq2xtzTGTjSnMb0NNmwMDfFy90dQ="; posting-host="af438498208016b9caf666ef1d671ce9" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:y+oeJo5rHPyHMMi7r523iN9m0gQ= sha256:9bcJpBWfTrognRqkuWsZ46/nRmGxEcmb8Fg6pzl3Y0Q= sha1:d7ZyFuFe6Ek0MLaE8ibUkZ6u7RA= sha256:M7niD11rnUWpUu1Jg0+wQ8ueThmuUMWFVCLCbK3K3js= Content-Language: en-US In-Reply-To: <11ctq02$1ohj1$1@kst.eternal-september.org>