Da Vinci Machine Project and Tail Call Optimization
> We are extending the JVM with first-class architectural support
> for languages other than Java, especially dynamic languages.
In my view, the best thing the Java people can do to support many
dynamic languages, including Lua, is to fix stack inspection so that
all Java method calls in the tail position replace the caller's stack
frame rather than push a fresh one. This would greatly ease the task
of translating Lua into Java byte code. I bet it's very hard to fix
this problem and maintain backward compatibility.
John Clements and Matthias Felleisen wrote a 2004 paper in
Transactions on Programming Languages and Systems, called "A
Tail-Recursive Machine with Stack Inspection". It describes the use
of continuation marks, a PLT Scheme feature, to implement stack
inspection. Has anyone thought about making continuation marks
available in the Lua VM? They apparently make a nice debugging
interface, among other things.