Date: Sat, 31 Dec 2022 01:06:52 -0500
On Fri, Dec 30, 2022 at 8:28 PM Yuri via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> 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<<().
`operator<<` is not a "C++-native string formatting construct". It's a
function of the C++ standard library. It is defined *entirely* by the
C++ standard library. Yes, the ability to overload `operator<<` is a
language feature, but its use as string formatting is 100% standard
library stuff.
Also, it's a very bad part of the C++ standard library, as it's built
atop the terrible stream interface. The `std::format` based system is
way better.
<std-proposals_at_[hidden]> wrote:
>
> 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<<().
`operator<<` is not a "C++-native string formatting construct". It's a
function of the C++ standard library. It is defined *entirely* by the
C++ standard library. Yes, the ability to overload `operator<<` is a
language feature, but its use as string formatting is 100% standard
library stuff.
Also, it's a very bad part of the C++ standard library, as it's built
atop the terrible stream interface. The `std::format` based system is
way better.
Received on 2022-12-31 06:07:04