
Understanding the Clojure `trampoline' - twism
http://pramode.net/clojure/2010/05/08/clojure-trampoline/
======
shaunxcode
this is cool - but the real magic lies with in recur right? How is that
implemented in clojure itself or does that require bytecode magic?

~~~
arohner
recur does two things: it checks that the call is in the tail position, and
calls the JVM bytecode to GOTO the top of the function.

The JVM has the bytecode to goto inside the current function, but doesn't have
the instruction to jump to another function in constant space, which is why
recur is the way it is.

~~~
CodeMage
Lots of nice info on SO on JVM and tail call optimization:

[http://stackoverflow.com/questions/105834/does-the-jvm-
preve...](http://stackoverflow.com/questions/105834/does-the-jvm-prevent-tail-
call-optimizations)

