I appreciate you taking the time to give examples in D. People are often under the mistaken impression that Zig's compile time is revolutionary, from how it is excessively hyped, but are failing to realize that many other languages have similar or users can get similar results by doing things differently, because languages have different philosophies and design strategies.
For example, the creator of Odin, has stated in the past he rather come up with optimal solutions without metaprogramming, despite enthusiasts trying to pressure him to add such features into that language.
This is done in D using templates. For example, to turn a type T into a type T:
The compiler will deduce the correct return type for a function by specifying auto* as the return type: For conditional compilation at compile time, D has static if: Note that the static if does not introduce a new scope, so conditional declarations will work.The version is similar, but is intended for module-wide versions, such as:
Compile time execution is triggered wherever a const-expression is required. A keyword would be redundant.D's mixins are for generating code, which is D's answer to general purpose text macros. Running code at compile time enables those strings to be generated. The mixins and compile time execution are not the same feature. For a trivial example:
I'll be happy to answer any further questions