Date: Tue, 25 Jun 2019 15:36:47 -0700
> How does one readily achieve this?
While it is possible to achieve such formatting with moderate efforts
without `=`, the main question is whether it's actually useful. So I'll be
more specific this time: do you have an actual real-world use case in your
(or someone else's) codebase for this feature and, if yes, how common it
is? From my research of the existing facilities that have been providing
the feature for > 5 years it's next to unused.
> I'm not sure I agree that's broken.
The reason why I think it's broken is that `0x 4` is not a valid number
which is not a great feature for something that tries to only format
numbers.
- Victor
On Tue, Jun 25, 2019 at 12:25 PM Matthew Woehlke <mwoehlke.floss_at_[hidden]>
wrote:
> On 25/06/2019 15.03, Victor Zverovich via Std-Proposals wrote:
> > All but one uses of `=` with Folly Format or {fmt} that I've seen
> > (including an extensive search in one of the biggest C++ codebases) could
> > have been rewritten in a simpler way with the `0` flag. The only case
> that
> > I've found where `=` was used with fill other than `0` was a Folly Format
> > test case.
> >
> > Do you have any use case for `=` that you cannot express by other means?
>
> How does one readily achieve this?
>
> std::string s1 = std::format("{: =6}", 42); // s1 == "+ 42"
> std::string s2 = std::format("{: =6}", -5); // s2 == "- 5"
>
> That was my first assumption as to why one would want to use internal
> alignment in the first place...
>
> > The `=` alignment in P0645 comes from Python where it's pretty broken:
> >
> > >>> "{: =+#8x}".format(4)
> > '+0x 4'
>
> I'm not sure I agree that's broken.
>
> --
> Matthew
>
While it is possible to achieve such formatting with moderate efforts
without `=`, the main question is whether it's actually useful. So I'll be
more specific this time: do you have an actual real-world use case in your
(or someone else's) codebase for this feature and, if yes, how common it
is? From my research of the existing facilities that have been providing
the feature for > 5 years it's next to unused.
> I'm not sure I agree that's broken.
The reason why I think it's broken is that `0x 4` is not a valid number
which is not a great feature for something that tries to only format
numbers.
- Victor
On Tue, Jun 25, 2019 at 12:25 PM Matthew Woehlke <mwoehlke.floss_at_[hidden]>
wrote:
> On 25/06/2019 15.03, Victor Zverovich via Std-Proposals wrote:
> > All but one uses of `=` with Folly Format or {fmt} that I've seen
> > (including an extensive search in one of the biggest C++ codebases) could
> > have been rewritten in a simpler way with the `0` flag. The only case
> that
> > I've found where `=` was used with fill other than `0` was a Folly Format
> > test case.
> >
> > Do you have any use case for `=` that you cannot express by other means?
>
> How does one readily achieve this?
>
> std::string s1 = std::format("{: =6}", 42); // s1 == "+ 42"
> std::string s2 = std::format("{: =6}", -5); // s2 == "- 5"
>
> That was my first assumption as to why one would want to use internal
> alignment in the first place...
>
> > The `=` alignment in P0645 comes from Python where it's pretty broken:
> >
> > >>> "{: =+#8x}".format(4)
> > '+0x 4'
>
> I'm not sure I agree that's broken.
>
> --
> Matthew
>
Received on 2019-06-25 17:38:49