Re: pgindent && weirdness - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: pgindent && weirdness
Date
Msg-id CA+hUKG+O7G0eM30EmrOS-QCmBSAjfDU814yYxO6j2RHvZ2Jymw@mail.gmail.com
Whole thread Raw
In response to Re: pgindent && weirdness  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pgindent && weirdness  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List 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 by date:

Previous
From: maxzor
Date:
Subject: 1 Status of vertical clustered index - 2 Join using (fk_constraint)suggestion - 3 Status of pgsql's parser autonomization
Next
From: Bryn Llewellyn
Date:
Subject: Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.