How to parse text for a DSL at compile time? (C++)
stackoverflow.com
stackoverflow.com
Rust procedural macros are one of the reasons I started using Rust.
Nim's metaprogramming support is quite extensive, possibly even more so than Rust's. If this is something that interests you then you should check it out.
As an example of what's possible: async await in Nim is implemented entirely via a macro[1], the `=>` operator for closures is also implemented as a macro[2].
1 - Example chat app client using async await: https://github.com/dom96/nim-in-action-code/blob/master/Chap...
2 - Implementation of `=>`: https://github.com/nim-lang/Nim/blob/devel/lib/pure/future.n...
We're the compiler to invoke some function like that at compile time, it would be much more simple.
I'm not suggesting this exactally, or even something very similar, but serves as an example.
For now, abusing of the template system is still popular.
eg. Disclaimer "I am one of the primary developers of the Nim programming language, as well as many tools and libraries for Nim. I am also currently writing a book about Nim called Nim in Action."
That carries both more weight to your answer as you clearly know Nim very well as well as gives people the correct perspective.
This would result in a whole new breed of abominations but perhaps something decent would come of it
In lots of languages the macros run in the language itself, for example in Lisp, Scala or Nim.
In C++, compile time macros are run in two separate languages: 1 the "pre-processor" and 2 "C++ templates"
Another 'recent' language that addresses this to the point of being its significant existential justification is D
In Visual Studio, a good built-in mechanism for that is T4 text templates.