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

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: 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>, 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:07:35
Message-ID: CA+TgmoYiFzaEx2uKB3sf7PhWKM8-LajOGFBJW=45QRv7Qnao-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 29, 2024 at 10:03 AM Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> wrote:
> I feel like this is the type of change where there's not much
> discussion to be had. And the only way to resolve it is to use some
> voting to gauge community opinion.
>
> So my suggestion is for people to respond with -1, -0.5, +-0, +0.5, or
> +1 to indicate support against/for the change.
>
> I'll start: +1

-1. I occasionally run into situations where I'm like "ah, it would be
nicer to declare this in the middle of the block". But for every 1
time that happens, there are probably 10 times where it's helpful to
me to be able to look at the top of the block and see all of the
variable declarations in one place. Plus, a lot of times, this urge to
declare mid-block is a sign that I've made that block too big and
complex and I need to refactor and simplify.

The fact that all of our code uses a consistent style is awfully nice, too.

The main argument I see for changing anything is that we do a lot of
things on this project that many people consider old-fashioned, and it
may discourage some younger developers from getting involved in the
project. I doubt that this is anywhere close to the biggest problem we
have in that area, but if we do end up changing it I'll console myself
with the thought that maybe we're usefully modernizing something.

Personally, though, I prefer the status quo, where the correct
location of a declaration for a particular identifier is largely an
objective question rather than a subjective question. We are not in
need of more bikeshedding targets.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-01-29 17:11:48 Re: psql: add \create_function command
Previous Message Pavel Stehule 2024-01-29 17:05:42 Re: psql: add \create_function command