public inbox for [email protected]
help / color / mirror / Atom feedFrom: Thomas Munro <[email protected]>
To: Jelte Fennema-Nio <[email protected]>
Cc: Bertrand Drouvot <[email protected]>
Cc: [email protected]
Subject: Re: Safer hash table initialization macro
Date: Fri, 5 Dec 2025 14:29:48 +1300
Message-ID: <CA+hUKG+TuQPXtfkaam6trfLrk+OXf89zUt7Jx27zEY-y8i1swA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <aS2b3LoUypW1/[email protected]>
<CAGECzQSHb6FxuSdYNY7tt8SKFw2dianACvkExrWRmTBfy-CkjQ@mail.gmail.com>
<aTAcV/[email protected]>
<[email protected]>
On Fri, Dec 5, 2025 at 4:30 AM Jelte Fennema-Nio <[email protected]> wrote:
> I'm a bit on the fence about the C11 _Generic code to determine whether
> we should use HASH_BLOBS or HASH_STRINGS based on the type of the key.
> It works really nicely in practice, but I'm worried it's a bit too much
> magic. Probably we should at least have an override to allow using
> HASH_BLOBS anyway for a char array (in case it's not null terminated).
How much of our header stuff is supposed to work from C++ too? I
assume that if this is passing cpluspluscheck then it's only because
those _Generic macros aren't being expanded. I suppose you could
write the typeof-based version you already hinted at, but only use it
for __cplusplus__ (where typeof exists as decltype).
What I mean is, if something like DuckDB (C++ IIRC) wants to actually
use these APIs with the new interfaces, they won't work if the macros
expant to _Generic (not legal C++), but a typeof/decltype-based
version should work just fine, but at the same time I don't think
we'd want to use typeof just because it is available, or we'd never
test the _Generic version: all 3 C compilers have something we can use
for typeof, it's just not standard C before C23, and we want
PostgreSQL to be a valid C11 program and actually have coverage of
those code branches.
Another consideration is what impact we have on the Rust world, and
potentially other languages used for extensions that call C via FFI
etc, if we start using _Generic in our public interfaces, as opposed
to just using it in smaller ways as part of our internal assertions
and C implementation code that doesn't affect extensions. Of course
people using C APIs have to deal with the complexities of C evolution
too, I'm not saying that's a blocker, I'm just trying to think through
the impact of these sorts of API changes on the ecosystem.
view thread (17+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Safer hash table initialization macro
In-Reply-To: <CA+hUKG+TuQPXtfkaam6trfLrk+OXf89zUt7Jx27zEY-y8i1swA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox