C++ Logo


Advanced search

Re: [wg14/wg21 liaison] WG14 feelings about F-strings for C

From: Niall Douglas <s_sourceforge_at_[hidden]>
Date: Thu, 26 Oct 2023 11:50:25 +0000
On 25/10/2023 21:26, Joseph Myers wrote:
> On Wed, 25 Oct 2023, Niall Douglas via Liaison wrote:
>> As under that paper, the C preprocessor would turn that into:
>> ```
>> int main(int argc, const char argv[]) {
>> char buffer[256];
>> for(int n = 0; n < argc; n++) {
>> puts(_FormatNString(buffer, 256, "arg {}: {}\n", n, argv[n]));
>> }
>> return 0;
>> }
>> ```
> What's the intended way of handling internationalization with this
> feature, in cases where current code passes the printf format string to a
> lookup function such as gettext (to be included in the next revision of
> POSIX) which returns a translated version of the format string that might
> use the POSIX extension for reordering format arguments (%2$s to refer to
> the second variable argument with a %s format, etc.) if reordering is
> appropriate for the language being translated to? Is there a way to
> handle an argument order determined by runtime lookup on the format string
> with this feature, as proposed or a natural extension thereto?

I couldn't find support for that in his draft paper, so I had to go ask.
It turns out that is unsolved.

I've made it clear that's a showstopper problem absolutely requiring it
to be solved before any further progress can be made.

I'm gathering from the general response here that WG14 is not opposed to
extending the preprocessor to implement F-strings in principle. It would
need a better proposition, and a working compiler fork obviously. I'll
pass that back to him.


Received on 2023-10-26 11:50:27