Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Metaprogramming in C++ is TC, but it's not what makes C++ TC by itself.


Yes, but it is the difference to other programming languages.

In C you cannot encode a Turing machine that is executed by the compiler at compile time. In Brainfuck you cannot encode a Turing machine that is executed by the compiler at compile time. In C++ you can encode a Turing machine that is executed by the compiler at compile time.

That is the difference we are discussing here.


Yes i now realize that, thanks for explaining further. The original comment was worded in a way that i misunderstood the claim.


>In C you cannot encode a Turing machine that is executed by the compiler at compile time.

But you can get quite close with macros


No. You would need the ability to write unbounded loops or unbounded recursion. You don't have that with the C preprocessor.

Yes, you can do a lot with the C preprocessor. You can also do a lot in languages that only have bounded loops and are therefore not Turing complete. You can either express nonterminating computations (Turing completeness), or you can't (still powerful, but dramatically less poweful). This question is binary. There is no fuzziness, there is no approximation, there is no "quite close".


You misunderstand. C++ is Turing-complete at compile time, due to template metaprogramming. This demonstrates that it isn't a context-free grammar.

This isn't true of all programming languages.


Thanks, i see what you were saying now, i misunderstood your original comment.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: