There's an excellent article about C++ templates over at kuro5hin.org, comparing them to SML, Lisp and Scheme and their very different, and in many ways superior and more elegant ways, of solving the same problems. Very constructive critique. I also learned something about templates, the only feature I haven't played around with in C++, I think.
Included in the article is this little gem, "ported" to more modern less C'ish C++:
It compiles with "
g++ -Wall -ansi -pedantic" on my OpenBSD
machine, but do yourself the favour to compile it with "
and read the resulting evil.s assembler file (I don't know
assembler, but I did grasp this output). You'll see that the
computations are carried out at compile time instead of at runtime, and this
is so obviously a very speed enhancing technique to use.
But the Lisp/Scheme and SML solutions are so very sweet, I wish I had the time and energy to sit down and study those things.
Author M. G. Liebach
LastMod 2016-05-01 (9fc4632)