Arc Forumnew | comments | leaders | submitlogin
3 points by fallintothis 2492 days ago | link | parent

Is this how most languages get tail call elimination?

Well, more languages do TCO than use CPS -- never mind a CPS interpreter. Though CPS is functionally equivalent to the more popular SSA (Static Single Assignment) form, it remains relatively unused; see I imagine the comment about using an interpreter is rooted in, a great chapter from a book that goes through writing a Scheme-like interpreter in Perl, including a CPS transform and TCO using a trampoline. (For quick info about what those mean, there's of course and

In fact, CPS benefits from TCO. By converting a program into explicit CPS, every function call becomes a tail call (to the current continuation); without TCO, stack space would run out quickly. Certain TCO implementations can also use CPS; see

A great discussion about TCO implementation is To get really into it, the master's thesis at talks about tail calls in GCC (I've not read it, but it looks interesting).

1 point by evanrmurphy 2491 days ago | link

Wish I could upvote you more than once. Great reply.