Comment by publicdebates
4 hours ago
> macro language is surprising for the newcomer, but you get used to it
This was one of the biggest paradigm shifts for me in mastering C. Once I learned to stop treating the preprocessor as a hacky afterthought, and realized that it's actually a first-class citizen in C and has been since its conception, I realized how beautiful and useful it really is when used the way the designers intended. You can do anything with it, literally anything, from reflection to JSON and YAML de/serialization to ad hoc generics. It's so harmonious, if unsightly, like the fat lady with far too much makeup singing the final opus.
D accomplishes this by using Compile Time Function Execution to build D source code from strings, and then inline compiling the D code. Learning a macro language is unnecessary, as it's just more D code.
This kind of thing is very popular among D users.
https://dlang.org/spec/statement.html#mixin-statement
https://dlang.org/spec/expression.html#mixin_expressions
> You can do anything with it, literally anything, from reflection to JSON and YAML de/serialization to ad hoc generics.
Wow. Do you have any pointers? I always thought random computation with it is hard, because it doesn't really wants to do recursion by design. Or are you talking about using another program as the preprocessor?