Re: Remove redundant initializations - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Remove redundant initializations
Date
Msg-id 153226.1624889723@sss.pgh.pa.us
Whole thread Raw
In response to Remove redundant initializations  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Responses Re: Remove redundant initializations
List pgsql-hackers
Peter Eisentraut <peter.eisentraut@enterprisedb.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



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: pgindent run
Next
From: Tom Lane
Date:
Subject: Re: pgindent run