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

Поиск
Список
Период
Сортировка
От Ashwin Agrawal
Тема Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays
Дата
Msg-id CALfoeitRcpmLiqHNQLGweJX0eP8HQEmPQLPPGG5PsA-ChCPwrA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Chapman Flack <chap@anastigmatix.net>)
Список pgsql-hackers

On Fri, Oct 4, 2019 at 8:49 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Jacob Champion <pchampion@pivotal.io> writes:
> On Fri, Oct 4, 2019 at 7:51 AM Tom Lane <tgl@sss.pgh.pa.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.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Problem with repalloc downsizing patch
Следующее
От: Chapman Flack
Дата:
Сообщение: Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays