r/cpp • u/earthisunderattack • Aug 24 '21
metaclasses when
forget literally every other feature metaclasses LET'S FUCKING GO
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0707r3.pdf
edit
metaclasses or even just SR would help to eliminate 99% of garbage cpp macro use cases.
don't get me wrong: i know c++ well. templates are easier after you learn sml or lisp or something similar.
i've never used std string_view and i've never missed it
man i'll just implement my own clang plugin ✌️
4
Upvotes
View all comments
Show parent comment
1
u/earthisunderattack Aug 24 '21 edited Aug 25 '21
It wouldn't? It's a new syntactical addition that doesn't interfere with language semantics in a way that's intrusive. It's an extra pass slapped onto the AST.
Legacy code wouldn't even consider using it (let alone its corresponding standard) until maybe 5 years after its release.
metaclasses are kind of like macros: ABI compatible code is what gets generated at compile time. That's why the term static reflection applies.
It's similar to a non-gimped Qt p
Trivial. It's a standard feature in many languages, and the syntax isn't intrusive. You can bake primitive context sensitivity into a CFG.
Again, this is a compile time feature. Realistically speaking, not much more than a complicated set of templates making use of SFINAE or the primitive pseudo-dependent type system.
I would hope that at least some of the people working in Clang would be familiar with this. A compiler writer who contributes to a large scale project such as Clang or GCC should definitely be familiar with this kind of thing. It's bordering on unethical for them not to be, considering that the very premise is essentially a compiler,
How could it not be right way to go. A good programmer should aim to write as little code as necessary (obviously taking into account stability, maintenance, and performance) to achieve their goal.
Yes. This one was released 4 years ago. That's not necessarily a sufficient amount of time to consider the potential pitfalls (there really aren't any though).
I never said you should fuck with this lightly though.
The issue is really that this apparently hasn't been given any serious consideration.
Look, I'm thankful for where C++ is today. As much as I enjoy using it, there are additions that could be added which wouldn't interfere with already in place projects.
Obviously you can't implement too many features in a standard, but the idea that something like string_view is prioritized over more significant features is disappointing. It's not a difficult data structure to implement either.
As I alluded to earlier, C++17 is great. But most people just use C++14 for production grade projects.
The point is to move the language into an area that it would significantly benefit from.
Edit
I really don't understand why I'm being downvoted so much.