Re: Use C99 designated initializers for some structs

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: David Steele <david(at)pgmasters(dot)net>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use C99 designated initializers for some structs
Date: 2018-08-29 21:41:42
Message-ID: CAEepm=3MyZJ1YAEyvwJHkPQGP8EREJ9WNWMjBFEV1XtYJLnQTw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 30, 2018 at 8:51 AM David Steele <david(at)pgmasters(dot)net> wrote:
> On 8/29/18 5:14 AM, Peter Eisentraut wrote:
> > On 29/08/2018 12:13, Peter Eisentraut wrote:
> >> Here is a patch to change some struct initializations to use C99-style
> >> designated initializers. These are just a few particularly egregious
> >> cases that were hard to read and write, and error prone because of many
> >> similar adjacent types.
> >>
> >> (The PL/Python changes currently don't compile with Python 3 because of
> >> the situation described in the parallel thread "PL/Python: Remove use of
> >> simple slicing API".)
> >>
> >> Thoughts?
>
> +1. This is an incredible win for readability/maintainability.

+1. Much nicer.

I know several people have the goal of being able to compile
PostgreSQL as C and C++, and this syntax is not in the C++ standard.
Happily, popular compilers seem OK with, and it's already been voted
into the draft for C++20. So no problem on that front.

--
Thomas Munro
http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-08-29 21:58:19 Re: buildfarm: could not read block 3 in file "base/16384/2662": read only 0 of 8192 bytes
Previous Message Andres Freund 2018-08-29 20:56:43 Re: Use C99 designated initializers for some structs