Re: Propose a new function - list_is_empty

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Propose a new function - list_is_empty
Дата
Msg-id 1121750.1660658637@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Propose a new function - list_is_empty  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: Propose a new function - list_is_empty  (Daniel Gustafsson <daniel@yesql.se>)
Список pgsql-hackers
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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Christoph Berg
Дата:
Сообщение: Re: pg_receivewal and SIGTERM
Следующее
От: Gurjeet Singh
Дата:
Сообщение: Re: Patch proposal: New hooks in the connection path