40 ms·
No, because TCO only results in a loop when you have recursion, but there are other situations in which TCO can be applied to create an unconditional jump. TCO
by betterunix2 6y ago
No, because TCO only results in a loop when you have recursion, but there are other situations in which TCO can be applied to create an unconditional jump. TCO can also be applied when there is a pointer to a function (jump to a pointer target), and so in theory can be used for the C++ vtable.
In some sense the reverse of what you said would be a better strategy: rewrite loops as tail calls. Doing that as part of the CPS conversion, and combining with TCO and a garbage collector, gives you a simple non-optimizing compiler for functional languages (but theoretically can be used for imperative languages like C, hence the conversion of a loop to a tail call).