Re:Proving that C++'s grammar is undecidable
by roca on Thursday April 30, 2020 @07:41PM
(#23037569)
Compile-time function evaluation is quite a different feature from macros. Most of what you would do with macros (e.g. output entirely new definitions of functions, types, etc) can't be done with constexpr at all.
And vice-versa.
Re:Proving that C++'s grammar is undecidable
by tines on Wednesday April 29, 2020 @02:08PM
(#23022260)
Yes. From what I understand, Rust's macros/generics are not Turing complete.
Re:Proving that C++'s grammar is undecidable
by steveklabnik on Wednesday April 29, 2020 @04:29PM
(#23023866)
They are. Procedural macros especially are a function that takes tokens and returns tokens, and have the full language at their disposal.
Re:Proving that C++'s grammar is undecidable
by tines on Thursday April 30, 2020 @11:43AM
(#23032092)
Ah interesting. But I imagine that token-based macros don't give you access to the types in the program being compiled do they? i.e. a c++ template can tell when two types are the same but a token level macro wouldn't be able to do that I think.
Re:Proving that C++'s grammar is undecidable
by steveklabnik on Thursday April 30, 2020 @11:45AM
(#23032113)
Correct.
- C++-17 (-20) constexpr is one century in advance in front of rust macro in term of power and what you can do with it. It is not even comparable.
- C++20 compile time execution is currently pretty clean and has nothing to do with this template mess shown here. Definitively not "half baked".