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

Поиск
Список
Период
Сортировка
Искать
От
Heikki Linnakangas
Тема
Re: Should we remove -Wdeclaration-after-statement?
Дата
Msg-id
71ee71bc-f23b-4e1d-9ec1-495a04cea144@iki.fi
Ответ на
Список
Дерево обсуждения
Should we remove -Wdeclaration-after-statement? Jelte Fennema-Nio <postgres@jeltef.nl>
Re: Should we remove -Wdeclaration-after-statement? Andres Freund <andres@anarazel.de>
Re: Should we remove -Wdeclaration-after-statement? Andrew Dunstan <andrew@dunslane.net>
Re: Should we remove -Wdeclaration-after-statement? Tom Lane <tgl@sss.pgh.pa.us>
Re: Should we remove -Wdeclaration-after-statement? Jelte Fennema-Nio <postgres@jeltef.nl>
Re: Should we remove -Wdeclaration-after-statement? Jelte Fennema-Nio <postgres@jeltef.nl>
Re: Should we remove -Wdeclaration-after-statement? Mark Dilger <mark.dilger@enterprisedb.com>
Re: Should we remove -Wdeclaration-after-statement? Isaac Morland <isaac.morland@gmail.com>
Re: Should we remove -Wdeclaration-after-statement? Mark Dilger <mark.dilger@enterprisedb.com>
Re: Should we remove -Wdeclaration-after-statement? Isaac Morland <isaac.morland@gmail.com>
Re: Should we remove -Wdeclaration-after-statement? Tom Lane <tgl@sss.pgh.pa.us>
Re: Should we remove -Wdeclaration-after-statement? Nathan Bossart <nathandbossart@gmail.com>
Re: Should we remove -Wdeclaration-after-statement? Noah Misch <noah@leadboat.com>
Re: Should we remove -Wdeclaration-after-statement? Robert Haas <robertmhaas@gmail.com>
Re: Should we remove -Wdeclaration-after-statement? Peter Eisentraut <peter@eisentraut.org>
Re: Should we remove -Wdeclaration-after-statement? "Euler Taveira" <euler@eulerto.com>
Re: Should we remove -Wdeclaration-after-statement? Robert Haas <robertmhaas@gmail.com>
Re: Should we remove -Wdeclaration-after-statement? Heikki Linnakangas <hlinnaka@iki.fi>
Re: Should we remove -Wdeclaration-after-statement? Robert Haas <robertmhaas@gmail.com>
Re: Should we remove -Wdeclaration-after-statement? Andres Freund <andres@anarazel.de>
Re: Should we remove -Wdeclaration-after-statement? Tom Lane <tgl@sss.pgh.pa.us>
Re: Should we remove -Wdeclaration-after-statement? Andres Freund <andres@anarazel.de>
Re: Should we remove -Wdeclaration-after-statement? jian he <jian.universality@gmail.com>
Re: Should we remove -Wdeclaration-after-statement? Ranier Vilela <ranier.vf@gmail.com>
On 29/01/2024 19:07, Robert Haas wrote:
> On Mon, Jan 29, 2024 at 10:03 AM Jelte Fennema-Nio  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.

-0.5 from me, for exactly those reasons Robert said. I wouldn't mind 
removing the compiler flag as long as we mostly keep the current style 
of declarations at top, with exceptions when it really makes sense. But 
in practice it would open the floodgates and make things worse overall.

You can also add curly braces to introduce a block like this:

     do_stuff();
     {
         int i = 123;

         do_more_stuff(i);
         ...
     }

I know many people dislike that too, though. I think it's usually better 
than declaring a variable in the middle of a block, because it also 
makes you think how long the variable needs to be in scope.

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

People writing extensions or hacking on their own forks of PostgreSQL 
are free to do whatever they like. And I don't mind reviewing patches 
that don't follow the usual guidelines to the letter, stylistic things 
like this are easy to fix before committing. I don't feel like we're 
forcing these rules upon others.

-- 
Heikki Linnakangas
Neon (https://neon.tech)



В списке pgsql-hackers по дате отправления
От: Tristan Partin
Дата:
Сообщение: Re: meson + libpq_pipeline
От: Pavel Stehule
Дата:
FAQ