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

2021-08-21 Thread Ranier Vilela
Em sáb., 21 de ago. de 2021 às 12:02, Andrew Dunstan escreveu: > > On 8/20/21 12:30 PM, Ranier Vilela wrote: > > > > > > There is a reason why GMs Brian Kernighan and Dennis Ritchie made the > > C89, less buggy. > > IMHO C99 makes it easy to make more mistakes. > > One more step and we won't even

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

2021-08-21 Thread Andrew Dunstan
On 8/20/21 12:30 PM, Ranier Vilela wrote: > > > There is a reason why GMs Brian Kernighan and Dennis Ritchie made the > C89, less buggy. > IMHO C99 makes it easy to make more mistakes. > One more step and we won't even need to declare a variable. > > I've used both styles in different languages

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

2021-08-20 Thread Ranier Vilela
Em sex., 20 de ago. de 2021 às 12:29, Jelte Fennema < jelte.fenn...@microsoft.com> escreveu: > 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

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

2021-08-20 Thread Jelte Fennema
Oops. I'm sorry. That previous email looked horrible in plaintext. Please regard that as unsent. Same email, but second try: > 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 t

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

2021-08-20 Thread Jelte Fennema
ust 19, 2021 20:57 To: Chapman Flack Cc: Ranier Vilela ; Jelte Fennema ; pgsql-hack...@postgresql.org Subject: [EXTERNAL] Re: Allow declaration after statement and reformat code to use it [You don't often get email from br...@momjian.us. Learn why this is important at http://aka.ms/Learn

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

2021-08-19 Thread Michael Paquier
On Thu, Aug 19, 2021 at 10:34:04AM -0400, Tom Lane wrote: > Ranier Vilela writes: >> C needs readability, not fewer lines. >> Aside from horrible code, it doesn't improve 0.1% on anything. >> I think it's a bad idea and I'm strongly against it. > > Same here. We have thirty-ish years worth of co

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

2021-08-19 Thread Bruce Momjian
On Thu, Aug 19, 2021 at 11:40:44AM -0400, Chapman Flack wrote: > 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

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

2021-08-19 Thread Tom Lane
Chapman Flack 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.

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

2021-08-19 Thread Chapman Flack
On 08/19/21 09:38, Ranier Vilela wrote: >> 2. Declarations are closer to the actual usage. This is advised by the >> "Code Complete" book [2] and has the following advantages: >>a. This limits variable scope to what is necessary. Which in turn makes >> the mental model you have to keep of a fun

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

2021-08-19 Thread Tom Lane
Ranier Vilela writes: > Em qui., 19 de ago. de 2021 às 08:50, Jelte Fennema < > jelte.fenn...@microsoft.com> escreveu: >> ## Why would we want this? >> 1. It removes 23328 lines of code that don't have any impact on how the >> code behaves [1]. This is roughly 2.7% of all the lines of code in the

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

2021-08-19 Thread Ranier Vilela
Em qui., 19 de ago. de 2021 às 08:50, Jelte Fennema < jelte.fenn...@microsoft.com> escreveu: > ## What is this? > > It's a draft patch that replaces code like this: > ```c > pg_file_unlink(PG_FUNCTION_ARGS) > { > char *filename; > requireSuperuser(); > filename = convert_and_check_filename(PG_GE