3 ms·
And you can do precisely the same thing in C++ if you're willing to write somewhat non-trivial template code. This kind of thing is more surprising to Java pro
by derleth 15y ago
And you can do precisely the same thing in C++ if you're willing to write somewhat non-trivial template code.
This kind of thing is more surprising to Java programmers, I daresay, because the idea compiling a program being Turing-complete is not covered in most Java programming courses.
(Problems are Turing-complete; languages are Turing-equivalent, if you ignore the fact the Universe is finite.)
- danieldk 15y agoSomething like this? https://gist.github.com/1388217 https://gist.github.com/1388217 Crashes clang, reaches maximal template depth in g++. Seems there is no tail call optimization for templates ;).
- exDM69 15y ago"And you can do precisely the same thing in C++ if you're willing to write somewhat non-trivial template code." The template code required to cause non-termination in template instantiation is a very trivial infinite loop. Simple metaprogramming with templates is not very hard, it's kind of like doing lisp with template parameters. Variadic templates (in c++11) make this a whole lot simpler.
- philbarr 15y agoYou're suggesting that Turing-completeness of compilers IS covered in most C++ programming courses? I doubt it.