4 ms·
I don’t understand the argument. Rust proc macros have some level of introspection. I can retrieve the type information from the AST. The reason you can’t alway
by aabhay 2y ago
I don’t understand the argument. Rust proc macros have some level of introspection. I can retrieve the type information from the AST. The reason you can’t always know whether something has a trait is because that constraint isn’t implemented at the type level. For example what if a trait is a subtrait of something inside the proc macro?
While I don’t have evidence, I’m guessing that true introspection would require turing completeness, allowing your code to never compile.
- steveklabnik 2y agoI don’t know what argument you think is being made here, this is just an explanation of some features. It’s not making an argument.
- aabhay 2y agoIt seems to be making the argument that C++ 26 has new reflection features that outperform Rust code gen due to the unavailability of high quality proc macro features.
- steveklabnik 2y agoI see. I genuinely think the author is just trying to show off a new C++ feature, not argue that it's better than the Rust feature is. Of course, since they are different, there is comparison necessary, and proc macros aren't perfect. But it's really just about explaining why this is a cool feature, not trying to say Rust is bad.
- wrs 2y agoUnless I misread, there is an assertion that Rust macros have to implement a lot of “compiler” logic themselves (whether or not through a separate crate) that is [will be] unnecessary with the new C++ feature. So not “bad”, but more clunky for the annotation implementor.
- steveklabnik 2y agoFor sure. That's just a statement of fact, though. This is why folks are interested in Rust having reflection as well.