Cl-cpp-generator – A Common Lisp library to generate C/C++ code
github.com
github.com
Generating C code as a "portable assembly language", to take advantage of deeply evolved optimizing C compilers, is a common practice that apparently originated with the first C++ compiler, Cfront. At the time, the technique was not widely understood, and Cfront was often dismissed, sometimes dishonestly, sometimes ignorantly, as "just a preprocessor".
Nowadays, it has become more common to target LLVM, instead, and all our compilers may be similarly dismissed as "just preprocessors" for that. Or not.
So we might wonder why this library does not generate LLVM, instead. One good answer would be that there are still execution targets for which there is an adequate C compiler but no LLVM target.
I was language-lawyering in the comp.lang.c newsgroup in the 1990's and early 2000's.
That bit come up from time to time: "hey you stupid, there is no such language as c/c++!" I participated in that myself, sadly.
Most of the time, it wasn't what the person meant (that there is such a language). Just that they are looking for a solution in either C or C++ or whatever.
(In fact, there is a language that could be plausibly be called "C/C++": useful programs can be written that compile as either C or C++. The easiest way to code that way is to stick to the C90 dialect, and avoid the few C++ incompatibilities that it has. I have considerable experience in this area, that is ongoing.)
In this case, the generator can perhaps be used for C, if C++ features are avoided, so it means C or C++. Just like "if/when" or "he/she".
HN guideline: Please respond to the strongest plausible interpretation of what someone says, not a weaker one that's easier to criticize. Assume good faith.
It is always better to write what you mean, and not make people guess.
You could generate LLVM code that does that, but the point is integrating the generated code in a bigger project