7 ms·
Why not write a compiler that performs the metaprogramming? The input for this compiler could be in some clean, well thought-out language, and the output could
by amelius 12y ago
Why not write a compiler that performs the metaprogramming?
The input for this compiler could be in some clean, well thought-out language, and the output could be dirty C++ template metaprogramming code.
- lmm 12y agoWhat's the use case? In a scenario where you're able to use another language/tool, why would you want a C++ template metaprogramming stage at all? (The only use cases I'm aware of for C++ template metaprogramming are where you have a hard requirement to do something in standard C++, or for the sake of doing it in C++ template metaprogramming)
- pbsd 12y agoI have seen more than one such compiler, usually from Haskell-like dialects to C++ metafunctions (e.g., http://gergo.erdi.hu/projects/metafun/ http://gergo.erdi.hu/projects/metafun/). In this case the metaprogramming seems unnecessary---even assuming that it makes any sense to run a snake game at compile time---since C++14's relaxed `constexpr` functions are a much more readable way to achieve the same thing. Metaprogramming is only required now when types need to be computed; most of everything else is more cleanly done with `constexpr`.
- praptak 12y agoIt's what Lisp does, only both the compiler and the target language is Lisp.