News for hackers. Stuff that matters.
Re:Creating a Common Lisp implementation, part 1 [video] by betterunix2 on Tuesday August 25, 2020 @08:32PM (#24277847)
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).

There are no comments on this comment yet.