On Saturday, 6 April 2019 at 12:06:22 UTC, Robert M. Münch wrote:
I like the idea of DSL which are transpiled into the target
language that gets compiled or are interpreted at run-time.
Since D is compiled, I would like to transpile the DSL to D at
compile-time.
The idea is, that I can write a string (or maybe even a scope
block?) in my DSL and use a CTFE grammer to transpile the code.
Does anybody has any experience with such an approach? Are the
CTFE facilities overall sufficient to implement something like
this? Or is there a much better approach?
One of the most famous examples here is Vibe.d's Diet template:
https://github.com/rejectedsoftware/diet-ng
tl;dr: CTFE is sufficient, but the downside is that it will be
run everytime you build your program which can increase the build
time.