From: | Ashwin Agrawal <aagrawal(at)pivotal(dot)io> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Jacob Champion <pchampion(at)pivotal(dot)io>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays |
Date: | 2019-10-04 17:44:13 |
Message-ID: | CALfoeitRcpmLiqHNQLGweJX0eP8HQEmPQLPPGG5PsA-ChCPwrA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Oct 4, 2019 at 8:49 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Jacob Champion <pchampion(at)pivotal(dot)io> writes:
> > On Fri, Oct 4, 2019 at 7:51 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >> I concur with Joe here. The reason why some of the existing
> >> memset's use "false" is for symmetry with other places where we use
> >> "memset(p, true, n)" to set an array of bools to all-true.
>
> > Why introduce a macro at all for the universal zero initializer, if it
> > seems to encourage the construction of other (incorrect) macros?
>
> Well, the argument is that some people might think that if {0} is enough
> to set all array elements to 0, then maybe {1} sets them all to ones
> (as, indeed, one could argue would be a far better specification than
> what the C committee actually wrote). Using a separate macro and then
> discouraging direct use of the incomplete-initializer syntax should help
> to avoid that error.
>
Seems avoidable overhead to remind folks on macro existence. Plus, for such
a thing macro exist in first place will be hard to remember. So,
irrespective in long run, {0} might get used in code and hence seems better
to just use {0} from start itself instead of macro/wrapper on top.
Plus, even if someone starts out with thought {1} sets them all to ones, I
feel will soon realize by exercising the code isn't the reality. If such
code is written and nothing fails, that itself seems bigger issue.
From | Date | Subject | |
---|---|---|---|
Next Message | Chapman Flack | 2019-10-04 18:05:41 | Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays |
Previous Message | Tom Lane | 2019-10-04 17:00:26 | Problem with repalloc downsizing patch |