I've watched Don't constexpr all the things, which is a talk explaining how Cirlce does meta-programming and I found it very interesting that it looks as simple as I as a newbie would imagine meta-programming should be, i.e. it can execute any C++ function or library function at compile time. Here are two interesting examples:
int i = 0;
int f() { return ++i; }
int main()
{
std::cout << (@meta f()) << std::endl; // Outputs 1
std::cout << (@meta f()) << std::endl; // Outputs 2
std::cout << i << std::endl; // Outputs 0
}
#include <fstream>
#include <iterator>
#include <string>
@meta std::ifstream f("file.txt");
@meta std::string str(std::istreambuf_iterator<char>(t),
std::istreambuf_iterator<char>());
const char file_contents[] = @string(str);
How does Circle's approach compare with D's (or with the vision of the direction of D's CTFE)? Is it likely that Circle's meta-programming also requires ten-thousands of lines of extra compiler code? I personally tend to prefer code generation over meta-programming, as I find that simpler to reason about and it works in any language, but I see the benefits of CTFE as well.