Re: Allow declaration after statement and reformat code to use it

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chapman Flack <chap(at)anastigmatix(dot)net>
Cc: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Jelte Fennema <Jelte(dot)Fennema(at)microsoft(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Allow declaration after statement and reformat code to use it
Date: 2021-08-19 16:27:25
Message-ID: 1760990.1629390445@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chapman Flack <chap(at)anastigmatix(dot)net> writes:
> I'm in sympathy with all of those points. I've never believed that the
> arbitrary separation of declaration from use that was forced by C < 99
> made anything more readable. If the project were started now from scratch,
> I would be all in favor of declaring at first use.

Yeah, if we were starting today, I'm sure we'd use C99 or C++ as our
baseline and not arbitrarily exclude some language features. But ...
we're not. The rule against declaration-after-statement was kept
after significant discussion, which you can find in the archives if you
look. We're not going to drop it just because one person shows up with
a patch to do so.

>>> It uses a Perl regex to search and replace! (obligatory jokes at the
>>> bottom of the email)

> However, even if such an idea were to get the green light, I think I would
> take the obligatory regex jokes seriously, and instead use something like
> srcML [0] and do the analysis and modification on proper parse trees.

Agreed. I think the odds of introducing bugs are near 100% if it's done
without using a tool that actually understands the code semantics.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2021-08-19 16:37:58 reporting TID/table with corruption error
Previous Message Fujii Masao 2021-08-19 16:12:11 Re: RFC: Logging plan of the running query