Robert Haas <robertmhaas@gmail.com> writes:
> On Mon, Aug 15, 2022 at 9:28 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> That's because the *correct* way to write it is either "alist == NIL"
>> or just "!alist".
> I think the alist == NIL (or alist != NIL) style often makes the code
> easier to read. I recommend we standardize on that one.
I have a general preference for comparing to NIL because (as Daniel
noted nearby) it reminds you of what data type you're dealing with.
However, I'm not up for trying to forbid the bare-boolean-test style
altogether. It'd be near impossible to find all the instances;
besides which we don't insist that other pointer checks be written
as explicit comparisons to NULL --- we do whichever of those seems
clearest in context. So I'm happy for this patch to leave either
of those existing usages alone. I agree though that while simplifying
list_length() calls, I'd lean to using explicit comparisons to NIL.
regards, tom lane