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

Поиск
Список
Период
Сортировка
От Euler Taveira
Тема Re: Should we remove -Wdeclaration-after-statement?
Дата
Msg-id ba1d3a6c-55ad-42d8-b8e1-ec94b1194fed@app.fastmail.com
обсуждение исходный текст
Ответ на Re: Should we remove -Wdeclaration-after-statement?  (Jelte Fennema-Nio <postgres@jeltef.nl>)
Список pgsql-hackers
On Mon, Jan 29, 2024, at 12:03 PM, 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 here. Unless you have a huge amount of variables, (1) is an issue. The most
annoying argument against the current style (declarations at the top of the
function) is (2). However, people usually say it is a code smell to have a big
chunk of code into a single function and that you need to split the code into
multiple functions. Having said that, it is easier to check if the variable V
is used because the number of lines you need to read is small. And it imposes
similar effort to inspect the code than your argument (3), (4), and (5).

One argument against it is if you use the "declare on first use" style, you
will spend more time inspecting the code if you are refactoring it. You
identify the code block you want to move and than starts the saga. Check every
single variable used by this code block and search for its declaration. It is
such a time consuming task. However, if you are using the "declare at the top"
style, it is a matter of checking at the top.

Keep both styles can be rather confusing (in particular for newbies). And as
Nathan said I don't see huge benefits moving from one style to the other.


--
Euler Taveira

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: Schema variables - new implementation for Postgres 15
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: Optmize bitmapword macros calc (src/backend/nodes/bitmapset.c)