3 ms·
> My question is, is there a real use-case for Turing-completeness inside a C++ compiler? If it isn't Turing-complete then there are some things you can't comp
by AnthonyMouse 12y ago
> My question is, is there a real use-case for Turing-completeness inside a C++ compiler?
If it isn't Turing-complete then there are some things you can't compute with it. If you want to do one of those things which could be computed at compile time then without it you would have to compute it at runtime. Which means it has to be computed on every execution rather than once by the compiler and if there is some logic error in the code you may not discover the error until that code is actually executed rather than having the compiler find it for you.
It also has the potential to save you a lot of duplication. You're basically asking the compiler to run a program to convert your C++ program into arbitrarily many similar-but-not-quite-the-same C++ programs, algorithmically. Because it's Turing-complete you can do any transformation with it. There is no edge case it can't handle which could cause you to need to write and maintain 500+ nearly identical copies of the same code instead, which is what can happen in e.g. Java.