From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Remove redundant initializations |
Date: | 2021-06-28 14:15:23 |
Message-ID: | 153226.1624889723@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> writes:
> There are certain parts of code that laboriously initialize every field
> of a struct to (some spelling of) zero, even though the whole struct was
> just zeroed (by makeNode() or memset()) a few lines earlier.
FWIW, I think that it's an intentional style choice to explicitly
initialize every field rather than relying on makeNode to have done so.
The primary case where I personally rely on that style is when adding a
new field to a struct. Currently it's possible to grep for some existing
field and add the new one beside it. Leaving out initializations by
relying on side-effects of makeNode makes that far riskier.
A different aspect is the one you mention parenthetically, which is
what values can we rely on to be all-zero-bits? Switching to this
style will embed assumptions about that to a far greater degree than
we have now, making the code less robust against changes.
I'm aware that there are opinions to the contrary, but I do not think
this is an improvement.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-06-28 14:21:57 | Re: pgindent run |
Previous Message | Andrew Dunstan | 2021-06-28 14:13:08 | Re: pgindent run |