
Claus Reinke wrote:
|Basically, the JVM lacks a native ability to do tail calls. It does |not have an instruction to remove/replace a stack frame without |executing an actual return to the calling method/function.
There is a conflict between preserving stack layout and efficient tail calls. Unfortunately, stack inspection appears to be used for security aspects in JVM. That doesn't make tail calls impossible, but may have slowed down progress as this argument always comes up in discussing tail calls on the JVM (since its byte code isn't just an internal detail, but an externally used API).
It's a bugbear, but it's not impossible: http://www.ccs.neu.edu/scheme/pubs/esop2003-cf.pdf http://www.ccs.neu.edu/scheme/pubs/cf-toplas04.pdf Maybe one day it'll be here. -- Live well, ~wren