News for hackers. Stuff that matters.
Re:Proving that C++'s grammar is undecidable by roca on Wednesday April 29, 2020 @01:30AM (#23015703)
If you really want that, it seems better to provide them properly like Rust proc-macros than to provide them in C++'s awful half-baked form.
Re:Proving that C++'s grammar is undecidable by adev_ on Wednesday April 29, 2020 @02:22AM (#23016024)
> If you really want that, it seems better to provide them properly like Rust proc-macros than to provide them in C++'s awful half-baked form.

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

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.
Re:Proving that C++'s grammar is undecidable by tines on Friday May 01, 2020 @02:04PM (#23044788)
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.
Re:Proving that C++'s grammar is undecidable by saagarjha on Wednesday April 29, 2020 @01:49AM (#23015813)
Rust’s compile-time meta programming is lacking at the moment, unfortunately. It doesn’t have const generics yet, and the standard library is a bit anemic and this extends to the type programming utilities as well.
Re:Proving that C++'s grammar is undecidable by pjmlp on Wednesday April 29, 2020 @02:26AM (#23016049)
C++'s awful half-baked form comes with 40 years of IDEs, libraries, GUI tooling, OS and GPGPU SDKs, so while I do like Rust, I rather use C++ for the time being, as clunky as it might be.