Re: strange case of "if ((a & b))"
Daniel Gustafsson <daniel@yesql.se>
From: Daniel Gustafsson <daniel@yesql.se>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Peter Smith <smithpb2250@gmail.com>,
Justin Pryzby <pryzby@telsasoft.com>,
Bruce Momjian <bruce@momjian.us>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-08-19T07:34:35Z
Lists: pgsql-hackers
> On 19 Aug 2021, at 05:08, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > Peter Smith <smithpb2250@gmail.com> writes: >> On Thu, Aug 19, 2021 at 4:29 AM Justin Pryzby <pryzby@telsasoft.com> wrote: >>> - state->oneCol = (origTupdesc->natts == 1) ? true : false; >>> + state->oneCol = origTupdesc->natts == 1; > > FWIW, I am definitely not a fan of removing the parentheses in this > context, because readers might wonder if you meant an "a = b = 1" > multiple-assignment, or even misread it as that and be confused. > So I'd prefer > > state->oneCol = (origTupdesc->natts == 1); +1, the parenthesis makes it a lot more readable IMO. -- Daniel Gustafsson https://vmware.com/
Commits
-
Clean up more code using "(expr) ? true : false"
- 68f7c4b57a27 15.0 landed
-
Clean up some code using "(expr) ? true : false"
- fd0625c7a9c6 15.0 landed