Hacker News new | ask | show | jobs
by 0xFFC 3155 days 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-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.

4 comments

It'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-ge...
Thank 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.

The 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.

You are correct. But there is another side too. $ makes the language way uglier than it is now, and C++ is ugly language already.
Why does it make C++ more ugly? Do you find PHP ugly too?
Next proposal will be about the new C++ logo, which will be, yes, a camel!
Its so much simpler :)
I agree, but $ doesn't make the language way more uglier than what it is now?
I 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.