Re: Should we remove -Wdeclaration-after-statement?

From: Isaac Morland <isaac(dot)morland(at)gmail(dot)com>
To: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
Cc: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, "ranier(dot)vf(at)gmail(dot)com" <ranier(dot)vf(at)gmail(dot)com>, chap(at)anastigmatix(dot)net
Subject: Re: Should we remove -Wdeclaration-after-statement?
Date: 2024-01-29 17:12:24
Message-ID: CAMsGm5fz3YLGWbe8m=FM4RFcsD8gFCg9GsDS8+nwAk9PLpwaUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 29 Jan 2024 at 10:42, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
wrote:

> I don't think anybody is proposing re-working the existing codebase. I
> understand this to be only about allowing new code to use the newer style.
> Personally, I like, as much as possible, to use initializations to const
> variables and avoid assignment operators, so I much prefer to declare at
> first (and usually only) assignment.
>
> I was responding to Jelte's paragraph upthread:
>
> > On Dec 27, 2023, at 9:59 AM, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
> wrote:
> >
> > But if the only reason not to remove the
> > warning is that then there would be two styles of declaration in the
> > codebase, then I'm happy to create another refactoring script that
> > moves declarations down to their first usage. (Which could then be run
> > on all backbranches to make sure there is no backpatching pain)
>
> I find that kind of gratuitous code churn highly unpleasant.
>

I stand corrected, and agree completely. It’s hard to imagine a change of
such a global nature that would be a big enough improvement that it would
be a good idea to apply to existing code. Personally I’m fine with code of
different vintages using different styles, as long as it’s understood why
the difference exists — in this case because tons of code has already been
written and isn’t going to be re-styled except possibly as part of other
changes.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2024-01-29 17:13:35 Re: Report planning memory in EXPLAIN ANALYZE
Previous Message Tom Lane 2024-01-29 17:11:48 Re: psql: add \create_function command