4 ms·
Are they really going to add $ to C++? Unbelievable. What was wrong with "reflexpr"? It is way more C++'ish than "$". Update: From Herb's blog : "Also, a voca
by 0xFFC 9y ago
Are they really going to add $ to C++? Unbelievable. What was wrong with "reflexpr"? It is way more C++'ish than "$".
Update: From Herb's blog :
"Also, a vocal minority in the committee strongly want a syntax that does not include the $ character (not just for $class, but also for $expr reflection) because they have large code bases that use $ in source code that is not C++ code but is processed to emit C++; removing $ is an easy change at any time and we’ll just follow what the committee decides for reflection syntax (in fact, the alternative syntax I showed in the endnote above removes the need to write $). So further work is needed on those items, but fortunately none of it affects the core model."
https://herbsutter.com/2017/07/26/metaclasses-thoughts-on-generative-c/#comment-39733 https://herbsutter.com/2017/07/26/metaclasses-thoughts-on-ge...
P.S. I really hope that vocal minory would win ;)
But overall the proposal is what I have been talking about for a long time.
- humanrebar 9y agoThe best way to add new language primitives without breaking anyone is to pick a syntax that currently fails to compile. `reflexpr interface {...}` could be declaring and initializing a global. `$class`, on the other hand, doesn't compile. One could also do `virtual class` or something, I guess, since `virtual class` is a combination of reserved keywords.
- ape4 9y agoIts so much simpler :)
- 0xFFC 9y agoI agree, but $ doesn't make the language way more uglier than what it is now?
- mattnewport 9y agoI don't see why, unless you have something particularly against the $ symbol? It seems to fit with existing syntax quite well, e.g. & gives the address of a thing, $ gives the reflection of a thing. Extending that to define a metaclass seems pretty natural.
- alphaalpha101 9y agoI think the negatives (ugliness) of having $ in a few places where you define metaclasses is outweighed by the positives (cleanliness) of replacing this: class foo { virtual ~foo() = 0; virtual void do_x() = 0; }; with this: interface foo { void do_x(); }; in thousands of places.
- aduitsis 9y agoNext proposal will be about the new C++ logo, which will be, yes, a camel!
- kevinnk 9y agoIt's still up in the air I think - you can see from his blog[1] that others in the the committee prefer a syntax more like meta::type interface(const meta::type source) { // … basically same code … }; [1] https://herbsutter.com/2017/07/26/metaclasses-thoughts-on-generative-c/ https://herbsutter.com/2017/07/26/metaclasses-thoughts-on-ge...
- 0xFFC 9y agoThank you, I didn't know that. This syntax makes much more sense. Considering C++ style programming. I am very interested in having Reflection in C++. But tbh $ makes it really awkward.