Re: pgindent && weirdness

Поиск
Список
Период
Сортировка
От Thomas Munro
Тема Re: pgindent && weirdness
Дата
Msg-id CA+hUKG+O7G0eM30EmrOS-QCmBSAjfDU814yYxO6j2RHvZ2Jymw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: pgindent && weirdness  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: pgindent && weirdness  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
On Fri, Jan 17, 2020 at 3:58 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> > On 2020-Jan-16, Tom Lane wrote:
> >> ... But I was hoping to
> >> hear Piotr's opinion before moving forward.

Me too.

Thinking about this again: It's obviously not true that everything
that looks like a function call is not a cast.  You could have
"my_cast(Type)" that expands to "(Type)" or some slightly more useful
variant of that, and then "my_cast(Type) -1" would, with this patch
applied, be reformatted as "my_cast(Type) - 1" because it'd err on the
side of thinking that the expression produces a value and therefore
the minus sign must be a binary operator that needs whitespace on both
sides, and that'd be wrong.  However, it seems to me that macros that
expand to raw cast syntax (and I mean just "(Type)", not a complete
cast including the value to be cast, like "((Type) (x))") must be rare
and unusual things, and I think it's better to err on the side of
thinking that function-like macros are values, not casts.  That's all
the change does, and fortunately the authors of indent showed how to
do that with their existing special cases for offsetof and sizeof; I'm
just extending that treatment to any identifier.

Is there some other case I'm not thinking of that is confused by the
change?  I'm sure you could contrive something it screws up, but my
question is about real code that people would actually write.  Piotr,
is there an easy way to reindent some large non-PostgreSQL body of
code that uses a cousin of this code to see if it gets better or worse
with the change?



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

Предыдущее
От: maxzor
Дата:
Сообщение: 1 Status of vertical clustered index - 2 Join using (fk_constraint)suggestion - 3 Status of pgsql's parser autonomization
Следующее
От: Bryn Llewellyn
Дата:
Сообщение: Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.