C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Supporting f-strings in C++: draft-R1

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Mon, 16 Oct 2023 19:31:56 +0200
On 16/10/2023 18.54, Sebastian Wittmeier via Std-Proposals wrote:
> So the solution for option E with preprocessor support could be
>
> [Phases: https://eel.is/c++draft/lex.phases ]
>
> In Phase 3, when the decomposition into preprocessor tokens happens, the F or X string could be parsed and decomposed into a macro call with reordering of the format string and the {} parameters.
>
> [Separation into preprocessing tokens: https://eel.is/c++draft/lex.pptoken ]
>
> In Phase 4 that internal macro would create a call to std::format for F strings and a comma separated list for X strings and all other macro calls and preprocessor symbol expansions are done for the (previously curly embraced {} ) parameters.

So, you can't create an F string by string concatenation? That feels surprising.

Jens


>
>
> -----Ursprüngliche Nachricht-----
> *Von:* Jens Maurer <jens.maurer_at_[hidden]>
> *Gesendet:* Mo 16.10.2023 17:19
> *Betreff:* Re: [std-proposals] Supporting f-strings in C++: draft-R1
> *An:* std-proposals_at_[hidden];
> *CC:* Sebastian Wittmeier <wittmeier_at_[hidden]>;
> On 16/10/2023 15.47, Sebastian Wittmeier via Std-Proposals wrote:
> > How do F strings react, when they are concatenated out of different types of strings? Does each F one of them have to be complete? Or can a F be mixed with a normal string and the concatenation has to be complete?
>
> I'd like to point out that preprocessor tokenization happens in phase 3,
> macros are expanded in phase 4, and strings are concatenated in phases 5 and 6.
> See [lex.phases] for details.
>
> In which phase are these F or X strings supposed to be turned into
> something else that presumably ends up as a phase 7 C++ expression
> performing some formatting when evaluated?
>
> Jens
>
>

Received on 2023-10-16 17:32:02