Hacker News new | ask | show | jobs
by vinkelhake 442 days ago
You're looking at constructs mostly related to C++26 reflection. It's very new, so that might be why it looks like it's from a different planet. They necessarily had to invent some new syntax for it.

I think C++26's reflection is likely to be one of the most important changes to the language in a very long time.

1 comments

Did they have to invent new syntax for it? All other languages that have reflection have regular function calls for it. Why do ^^X instead of reflect(X)?
Not very many languages have compile time reflection. This is more like macros and syntax splicing.

Still a reflect keyword could have worked. Some argued that in reflection heavy code you would reflect a lot and the keyword would be a lot of noise.

I don't know if the reflection papers have been voted in already (I forgot how to check), so the syntax might still be up for debate.

According to https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p29...

> The original TS landed on reflexpr(...) as the syntax to reflect source constructs and [P1240R0] adopted that syntax as well. As more examples were discussed, it became clear that that syntax was both (a) too “heavy” and (b) insufficiently distinct from a function call. SG7 eventually agreed upon the prefix ^ operator. The “upward arrow” interpretation of the caret matches the “lift” or “raise” verbs that are sometimes used to describe the reflection operation in other contexts.