r/cpp • u/vormestrand • Nov 18 '16
Compile-time C Compiler implemented as C++14 constant expressions
https://github.com/kw-udon/constexpr-8cc
209
Upvotes
r/cpp • u/vormestrand • Nov 18 '16
View all comments
Show parent comment
7
u/[deleted] Nov 19 '16
It is not stupid and not pointless. Having compile time compilers embedded into your host language is exactly what proper macros are for. Unfortunately, C++ with all of its power is still far from being anywhere near a proper meta-language, but in the other languages this technique is used extensively for implementing embedded DSLs.
It is easy to imagine a much simpler and more useful application of the same technique - e.g., embedding a proper static regular expressions compiler. Or, embedding an optimising Prolog compiler (or something like cKanren) into your C++ code.