Coding guidelines for braces + spaces - link 404's
Coding guidelines for braces + spaces - link 404's
От:
Kevin Burke <kevin@burke.dev>
Дата:
Hi,
I have been working on a patch for Postgres. I'm curious about the suggested style for braces around if statements - some places don't include braces around an if statement body, if the if statement body is a single line.
The "Coding Conventions" don't contain any advice here (although maybe they should link to the "Developer FAQ"?) https://www.postgresql.org/docs/devel/source.html
The Postgres Wiki has a bit that says to "See also the Formatting section in the documentation," but that link 404's, so I'm not sure where it is supposed to go.
Thanks,
Kevin
Re: Coding guidelines for braces + spaces - link 404's
От:
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Дата:
On 20.09.21 05:37, Kevin Burke wrote:
> I have been working on a patch for Postgres. I'm curious about the
> suggested style for braces around if statements - some places don't
> include braces around an if statement body, if the if statement body is
> a single line.
Generally, the braces should be omitted if the body is only a single
line. An exception is sometimes made for symmetry if another branch
uses more than one line. So
if (foo)
bar();
but
if (foo)
{
bar();
}
else
{
baz();
qux();
}
Re: Coding guidelines for braces + spaces - link 404's
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Kevin Burke writes: > The Postgres Wiki has a bit that says to "See also the Formatting section > in the > documentation," but that link 404's, so I'm not sure where it is supposed > to go. Obsolete link, evidently. It should point to https://www.postgresql.org/docs/devel/source-format.html Will fix. regards, tom lane