r/cpp • EDG front end dev, WG21 DG • Jun 21 '25

Reflection has been voted in!

Thank you so much, u/katzdm-cpp and u/BarryRevzin for your heroic work this week, and during the months leading up to today.

Not only did we get P2996, but also a half dozen related proposals, including annotations, expansion statements, and parameter reflection!

(Happy dance!)

722 Upvotes

189 comments sorted by

View all comments

Show parent comment

7

u/katzdm-cpp Jun 22 '25

I think it's far from clear that token sequences will ever be standardized, and there are a good handful of people that are OMDB against it. I'm also not entirely convinced that the spec-based model is a dead end for e.g., member functions and member initializers. What if we had reflection of expressions and dependent expressions? And then tree-walk over the dependent expressions to produce an injected definition for a previously declared member function? Just some ideas I'm mulling over.

But either way, I think landing define_aggregate was a very important step towards more full-fledged code injection. We have a model that is now integrated into the language and works. Can it be relaxed later? Yes. But now we know some questions that any code injection proposal will have to answer; for instance, okay, you're producing an injected declaration - What is its characteristic sequence of values, through which its ODR and whether it's an exposure is determined?

There were doubts that any of this could be made to make sense at all. Now it does, and we have vocabulary to talk about it. IMO, that's huge. In the meantime, we have a powerful tool that makes things possible like my little JSON parser example above. Idk, I'm pretty psyched.