Re: strange case of "if ((a & b))"

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: strange case of "if ((a & b))"
Date: 2021-05-10 06:27:13
Message-ID: YJjSQWcx1xno9vyB@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 28, 2021 at 02:40:09PM -0400, Tom Lane wrote:
> Justin Pryzby <pryzby(at)telsasoft(dot)com> writes:
>> These look strange to me - the inner parens don't do anything.
>> I wouldn't write it with 2x parens for the same reason I wouldn't write it with
>> 8x parens.
>
> Agreed, but shouldn't we just drop the excess parens rather than
> doubling down on useless notation?

Using a notation like ((a & b) != 0) to enforce a boolean check after
the bitwise operation is the usual notation I've preferred, FWIW. Do
you mean something different here?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-05-10 06:30:23 Re: Inaccurate error message when set fdw batch_size to 0
Previous Message Michael Paquier 2021-05-10 06:25:08 Re: strange case of "if ((a & b))"