C++ Logo

std-proposals

Advanced search

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

From: Chris Gary <cgary512_at_[hidden]>
Date: Sun, 15 Oct 2023 20:33:29 -0600
>
> This is rather out-of-bounds, but `{}` has been used by many
> languages. ...
>

C# for another. I think its really just an arbitrary continuation of "well,
we delineate things with these, so they might work here, too..."
I read somewhere about using '$' as a prefix operator for substitutions
between literals. This might play nicely with string concatenation, and
wouldn't need additional scanning of the string components.
My main interest in anything syntax-related is visibility and reduction of
cognitive delay. I see too many "{}" everywhere for them to stand out
without highlighting, but that's just me.


On Sun, Oct 15, 2023 at 8:07 PM Jason McKesson via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Sun, Oct 15, 2023 at 7:55 PM Chris Gary via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > Just some thoughts:
> >
> > I find it strange that the "{}" syntax was adopted instead of some
> variation on "%" or "introducer-then-parameters" instead of "scoped
> parameters".
> >
> > The former requires single-scope balancing, whereas the latter can be
> matched with a regular expression (depending on what is allowed), and is
> easier to validate.
>
> This is rather out-of-bounds, but `{}` has been used by many
> languages. C++ didn't invent it out of thin air; it was chosen in part
> to be familiar to users of languages that had already adopted it.
>
> Furthermore, the `{}` syntax was not intended to be used to evaluate
> arbitrary C++ expressions. So it's reasonable to expect some
> complexity when adopting a formatting syntax for a task it was never
> intended to handle.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-10-16 02:33:42