4 ms·
If your language is TC and thus supports general recursion, no algorithm can possibly exist for deciding whether a function is in fact total in the general case
by nyrikki 3y ago
If your language is TC and thus supports general recursion, no algorithm can possibly exist for deciding whether a function is in fact total in the general case.
As all primitive recursive functions are provably total, that is a place a compiler can work. But just using for loops gets you there too.
Total functions that are also pure functions are a pretty small set so there may be other reductions like the above. But don't depend on the compiler.
But I agree writing total functions from the start is the ideal if possible.