C++ Logo

sg7

Advanced search

Re: [SG7] [isocpp-ext] P2320: "The Syntax of Static Reflection" feedback request

From: Andrew Sutton <asutton.list_at_[hidden]>
Date: Tue, 16 Feb 2021 10:09:03 -0500
>
> > i
> > would love to see evidence of such tool existing to such extent that
> > claiming $ in C++ would be problematic.
> > Just one!
>
> My memory is not as capable as Ville's, so I'm certainly also at the
> risk of rehashing things. But I remember the following discussion
> elements. In the discussion that I attended the result was, "oh well,
> could be done". That might not be the authoritative conclusion that
> Ville witnessed.
>
> CMake wants to do fancy things with $ in code. But the committee's CMake
> friends stated that this should not matter to the committee.
>
> Tooling not based on proper C++ parsing was already majorly broken by
> digit separators.
>
> These smart arguments are not mine, I am merely quoting smart people.


One of the more practical issues is that there are C/C++ systems that use $
in identifiers, and both GCC and Clang provide options to allow it via the
-fdollars-in-identifiers. And in fact, both compilers seem to allow this
*by default*. And after some quick checking, the same is true for MSVC.
Because the extension is supported by 3/4s of the major compilers, there's
a good reason to believe that people are using it. The problem is that we
don't know how many systems actually rely on this feature, so we don't know
how to estimate the cost of breakage.

When I first starting working on this in 2015 or so, we were using $ for
reflection, and I could build my examples on Darwin because one of their
system headers actually had a $ in its name (related to strace IIRC). That
disappeared after a system update, but it wasn't something I could fix. The
problem isn't hypothetical.

Maybe we can do something clever like treating $ as both an identifier and
operator, which would just limit breakage to those codebases using plain $
as an identifier. But I don't see that as a real option.

Templating tools deserve special mention. There was an exhausting level of
discussion about the impact of digit separators on tooling. And the choice
to move ahead was only after we knew the syntax could be supported. I
suspect that CMake would be considerably less happy than they suggest if $
suddenly had meaning in C++ and they were forced to redesign their
templating syntax.

For me, the effort of "fixing" these issues is not worth the effort.

Received on 2021-02-16 09:09:15