🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++
Article #767

Re: does an expression in a logical statement need parenthesis for proper evaluation?

#767
From: Lynn McGuire
Date: Fri, 06 Nov 2026 21:29
55 lines
3127 bytes
On 11/6/2026 12:50 PM, Keith Thompson wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> On 06/11/2026 02:07, Lynn McGuire wrote:
>>> On 11/5/2026 5:42 PM, Lynn McGuire wrote:
>>>> Hi,
>>>>
>>>> Does an expression in a logical statement need parenthesis for
>>>> proper evaluation in C and/or C++?
>>>>
>>>> In other words, should
>>>>
>>>> if (j1 * i1 < 1) {
>>>>       goto L463;
>>>> }
>>>>
>>>> be
>>>>
>>>> if ((j1 * i1) < 1) {
>>>>       goto L463;
>>>> }
>>>>
>>>> Thanks,
>>>> Lynn
>>> Thank you all very much.  BTW, there were parenthesis in the old
>>> Fortran code but F2C stripped them out.  I put them back in for my
>>> comfort as I see them.
>>>
>>
>> Since you are generating the C++ code automatically, there should not
>> be a problem adding the parentheses.  Generated code that contains
>> "goto L463" is clearly not intended for humans anyway (at least, not
>> without a good deal of effort).
> 
> My understanding is that the C++ code being generated is intended to be
> maintained as C++ code.  Lynn can confirm or deny that.  He's using f2c
> and a lot of manual cleanup.
> 
> In this particular example:
> 
>      if ((j1 * i1) < 1)
> 
> I find the inner parentheses slightly distracting.  I'd wouldn't
> write it that way myself, but it wouldn't particularly bother me
> if I saw it in someone else's code, and I likely wouldn't mention
> it unless asked.
> 
> If this were my project, as long as I'm having to do substantial
> manual cleanup, I'd probably change it to:
> 
>      if (j1 * i1) < 1)...

Huh?  I am confused.  Aren't you missing a left parenthesis there?

Lynn
Technical Details
Message-ID: <11clgrd$2tiij$2@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11cj4a0$23796$1@dont-email.me> <11cj994$24m06$1@dont-email.me> <11ck0pr$2amtc$1@dont-email.me> <11cl7i3$2pbh3$1@kst.eternal-september.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!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: Fri, 6 Nov 2026 15:29:16 -0600
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <11clgrd$2tiij$2@dont-email.me>
References: <11cj4a0$23796$1@dont-email.me> <11cj994$24m06$1@dont-email.me>
 <11ck0pr$2amtc$1@dont-email.me> <11cl7i3$2pbh3$1@kst.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 06 Nov 2026 21:29:18 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3066451"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19WIxxeL9uta9UHRREaRs5WCG6lgMhoows="; posting-host="9424d41671042b4b3ea15a90032ad150"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:15/WHMNaPY7GnNPTm3F+AMokTsg= sha256:827as6xPHzCeFi5p3dAqB7Iy9HItHvmwcy4snnlykTc=
	sha1:Bw/CspYEFZ42b57eBM/a/Cza0nQ= sha256:i1S2mL1WNgj/x39sblARB4MtrtSKgEHkn9//k1lGGu0=
Content-Language: en-US
In-Reply-To: <11cl7i3$2pbh3$1@kst.eternal-september.org>