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

From Alvaro Herrera
Subject Re: pgindent && weirdness
Date
Msg-id 20200217153525.GA14354@alvherre.pgsql
Whole thread Raw
In response to Re: pgindent && weirdness  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: pgindent && weirdness
List pgsql-hackers
On 2020-Feb-17, Thomas Munro wrote:

> 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.

Hmm ... this suggests to me that if you remove these alleged special
cases for offsetof and sizeof, the new code handles them correctly
anyway.  Do you think it's worth giving that a try?  Not because
removing the special cases would have any value, but rather to see if
anything interesting pops up.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Optimize update of tables with generated columns
Next
From: Muhammad Usama
Date:
Subject: Re: [HACKERS] Transactions involving multiple postgres foreignservers, take 2