Date: Fri, 30 Dec 2022 17:28:29 -0800
On 12/28/22 09:00, Barry Revzin via Std-Proposals wrote:
> On the other hand this:
> fmt::print(f"threshold is {threshold}, time is now {time()}\n");
> is substantially better (though not much shorter) than this:
> fmt::print("threshold is {}, time is now {}\n", threshold, time());
fmt::print is a separate library so it can't appear in the C++ standard.
The C++ standard defines the basic C++ syntax, and then the standard
library.
The interpolated string feature can't be defined in any library,
though. Library functions like fmt::print() or std::format() parse
the format string and then match supplied arguments to placeholders.
This isn't what the interpolated string feature does. The interpolated
string should be defined as an element of C++ syntax.
operator<<() is the only C++-native string formatting construct, so
it is natural to tie interpolated strings to operator<<().
Yuri
> On the other hand this:
> fmt::print(f"threshold is {threshold}, time is now {time()}\n");
> is substantially better (though not much shorter) than this:
> fmt::print("threshold is {}, time is now {}\n", threshold, time());
fmt::print is a separate library so it can't appear in the C++ standard.
The C++ standard defines the basic C++ syntax, and then the standard
library.
The interpolated string feature can't be defined in any library,
though. Library functions like fmt::print() or std::format() parse
the format string and then match supplied arguments to placeholders.
This isn't what the interpolated string feature does. The interpolated
string should be defined as an element of C++ syntax.
operator<<() is the only C++-native string formatting construct, so
it is natural to tie interpolated strings to operator<<().
Yuri
Received on 2022-12-31 01:28:33