3 ms·
Would anyone like to explain in text form how this works? I've got as far as the use of <{ meaning to run at compile time, so the whole thing is going to be one
by pjc50 1y ago
Would anyone like to explain in text form how this works? I've got as far as the use of <{ meaning to run at compile time, so the whole thing is going to be one of those template metaprogramming stunts.
- gpderetta 1y agoit is "simply" a DSL implementing a full custom language that is run at compile time. As far as I can tell the DSL is implemented with the tried-and-true technique of expression templates[1] combined with constant evaluation and unrestricted template value parameters (although these days there are multiple options to implement compile time DSLs, up to compile time parsing of strings). As to why, I can't pretend to know the author mind, but I suspect they did it because they could, the project itself is the objective. [1] https://en.wikipedia.org/wiki/Expression_templates https://en.wikipedia.org/wiki/Expression_templates
- seiferteric 1y agoThe whole thing is a joke but presented in a serious manner. The idea is that if you know your program input at compile time you can turn everything into a constexpr which gets evaluated at compile time so your program is "ran" by the compiler instead of at run time. So he built a "runtime" that is actually ran by the compiler around this idea for fun.
- delta_p_delta_x 1y ago> So he built a "runtime" that is actually ran by the compiler around this idea for fun. Funnily enough, sufficiently enough of C++ is constexpr-able that it was the driving force for compile-time reflection in C++[1], which is not unlike what the author has done. Although the new syntax is much more readable than what the author chose to do with expression templates, it's still annoying, as is much of C++. But I still like it, so I am decidedly Stockholmed. [1]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p29...