5 ms·
Template Haskell and Rust proc macros aren't similar to pervasive CTFE. TH/procmacros just give you lexical tokens, you then parse them (typically adding a mon
by floatboth 5y ago
Template Haskell and Rust proc macros aren't similar to pervasive CTFE.
TH/procmacros just give you lexical tokens, you then parse them (typically adding a monstrous dependency on haskell-src-exts/syn) and emit AST.
The way D is designed, you don't need such a special facility because CTFE is everywhere. You can run normal functions at compile time. You can have compile-time "static if" and "static foreach" statements, and use various introspection calls (confusingly called "traits") in those.
Zig has similar "comptime" functionality. C++ now has "if constexpr" but not any of the introspection features.