From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Mark Dilger <hornschnorter(at)gmail(dot)com> |
Cc: | David Steele <david(at)pgmasters(dot)net>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Use C99 designated initializers for some structs |
Date: | 2018-08-30 16:54:41 |
Message-ID: | 20180830165441.a6eyu52n3n65v6m4@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2018-Aug-30, Mark Dilger wrote:
> static struct config_bool ConfigureNamesBool[] =
> {
> {
> {"enable_seqscan", PGC_USERSET, QUERY_TUNING_METHOD,
> gettext_noop("Enables the planner's use of sequential-scan plans."),
> NULL
> },
> &enable_seqscan,
> true,
> NULL, NULL, NULL
> },
Personally, I dislike this form -- it's very opaque and I have to refer
to the struct definition each time I want to add a new member, to make
sure I'm assigning the right thing. I welcome designated initializers
in this case even though it becomes more verbose. I don't think
explicitly initializing to NULLs is sensible in this case; let's just
omit those fields.
> What should the general rule be for initializing arrays of structs such as these?
I don't know what a general rule would be. Maybe we can try hand-
inspecting a few cases, and come up with a general rule once we acquire
sufficient experience.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2018-08-30 17:28:48 | Re: Add a semicolon to query related to search_path |
Previous Message | Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?= | 2018-08-30 16:54:23 | Re: [PATCH] Tab completion for ALTER DATABASE … SET TABLESPACE |