title: Why can't tail calls be optimized in JVM-based Lisps?
body: <p>Main question: I view the most significant application of tail call optimization (TCO) as a translation of a recursive call into a loop (in cases in which the recursive call has a certain form).  More precisely, when translated into a machine language, this would usually be translation into some sort of series of jumps.  Some Common Lisp and Scheme compilers that compile to native code (e.g. SBCL) can identify tail-recursive code and perform this translation.  JVM-based Lisps such as Clojure and ABCL have trouble doing this.  What is it about the JVM as a machine that prevents or makes this difficult?  I don't get it.  The JVM obviously has no problem with loops.  It's the compiler that has to figure out how to do TCO, not the machine to which it compiles.</p>
  
  <p>Related question: Clojure <em>can</em> translate seemingly recursive code into a loop: It acts as if it's performing TCO, if the programmer replaces the tail call to the function with the keyword <code>recur</code>.  But if it's possible to get a compiler to identify tail calls--as SBCL and CCL do, for example--then why can't the Clojure compiler figure out that it's supposed to treat a tail call the way it treats <code>recur</code>?</p>
  
  <p>(Sorry--this is undoubtably a FAQ, and I'm sure that the remarks above show my ignorance, but I was unsuccessful in finding earlier questions.)</p>