Re: pgindent versus struct members and typedefs

Поиск
Список
Период
Сортировка
От Chao Li
Тема Re: pgindent versus struct members and typedefs
Дата
Msg-id B55A39FB-97F4-4869-A2A3-59429486ED5F@gmail.com
обсуждение исходный текст
Ответ на Re: pgindent versus struct members and typedefs  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: pgindent versus struct members and typedefs
Список pgsql-hackers

> On Dec 3, 2025, at 07:13, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Chao Li <li.evan.chao@gmail.com> writes:
>>> On Dec 3, 2025, at 06:51, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> In this case, I think pgindent is indirectly enforcing good style.
>>> I do not like omitting braces around anything that's more than one
>>> line; readers have to pay close attention to whether the code is
>>> doing what it was intended to.
>
>> For “one line”, do you mean only a single line of statement or one line statement plus one line comment?
>
> In my head, a comment and a statement are two lines, and so need
> wrapping braces as much as two statements would do.  I realize that
> C compilers think differently, but for readability and modifiability
> reasons that's the approach I take.
>

Totally agreed. In my first job at Lucent Technologies, the coding standard was that braces should always be added even
ifa clause has only one line of code. I remember one of the explanations was like, if braces has been added, then later
whena new line of code is added to the clause, there is only one line of diff, otherwise braces need to be added, so it
wouldbe 3 lines of diffs. 

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







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