Quote:Original post by Polymorphic OOPA recursion limit would be fine if there were some other form of iteration, but a language without a way to iterate (or recurse) indefinitely cannot define a program that will not halt. Thus, the halting problem does not apply to such a language. The halting problem does not apply to templates, because it's valid for the compiler to force them to halt. The halting function for templates can thus be defined to be:Quote:Original post by Extrarius
Since a recursion limit is allowed, templates CAN be turing complete (if your specific compiler has no recursion limit), but they don't HAVE to be. Thus, by the standard, you can't count on templates being turing complete.
Not at all. By standard you can consider the turing complete. There are always going to be limits for tons of features in any language implementation, not just templates in C++; that doesn't make them any less turing complete, acknowledging them is just being realistic. The C++ standard, for instance, has dozens of recommendations for minimum compiler limits in other areas of the language -- that doesn't mean that going beyond them is nonstandard code, they are just recommendations and don't imply compliance on any level.
Templates are turing complete, it's just that a compiler is generally going to have limits, just like there are often limits for many other features of any language. They can still theoretically be recursively instantiated forever, whether your compiler can handle it or not is another story. The standard merely acknowledges that fact and provides reasonable guidelines for an implementor to follow as recommendations.
A compiler for any functional language may have a limit to how deep recursion goes, that doesn't make the language any less turing complete, again, it's just being realistic.[...]
Halt(Template MetaProgram) = true
in an entirely standards-compliant compiler. If templates were turing complete, this fact would prove that many things with 'proven undecidability' are actually decidable and would make many very famous people quite unhappy.
In C (and, provably, any turing complete language), it is possible to create a program that will iterate indefinitely.