Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: michael(at)paquier(dot)xyz
Cc: thomas(dot)munro(at)gmail(dot)com, amit(dot)kapila16(at)gmail(dot)com, andres(at)anarazel(dot)de, tgl(at)sss(dot)pgh(dot)pa(dot)us, bruce(at)momjian(dot)us, chap(at)anastigmatix(dot)net, aagrawal(at)pivotal(dot)io, pchampion(at)pivotal(dot)io, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays
Date: 2019-10-17 11:28:12
Message-ID: 20191017.202812.1045027348890780165.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 17 Oct 2019 16:30:02 +0900, Michael Paquier <michael(at)paquier(dot)xyz> wrote in
> On Thu, Oct 17, 2019 at 06:37:11PM +1300, Thomas Munro wrote:
> > -1 for these macros.
> >
> > These are basic facts about the C language. I hope C eventually
> > supports {} like C++, so that you don't have to think hard about
> > whether the first member is another struct, and recursively so … but
> > since the macros can't help with that problem, what is the point?
>
> FWIW, I am not convinced that those macros are an improvement either.

FWIW agreed. I might have put +1 if it had multpile definitions
according to platforms, though.

> > I am reminded of an (apocryphal?) complaint from an old C FAQ about
> > people using #define BEGIN {.
>
> This one? Wow.
> http://c-faq.com/cpp/slm.html

I remember this.

Though the new macro proposed here doesn't completely seems to be a
so-called nonsyntactic macro, but the syntax using the macro looks
somewhat broken since it lacks {}, which should be there.

bool nulls[Natts_pg_collection] = INIT_ALL_ELEMS_ZERO;

We could abuse the macro for structs.

pgstattuple_type stat = INIT_ALL_ELEMS_ZERO;

This is correct in syntax, but seems completely broken.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dagfinn Ilmari Mannsåker 2019-10-17 11:34:44 Re: Remaining calls of heap_close/heap_open in the tree
Previous Message M Tarkeshwar Rao 2019-10-17 11:16:29 Can you please tell us how set this prefetch attribute in following lines.