scala doesn't optimize general tail calls, either (only direct tail recursion of final methods). If you want to optimize tail calls on the JVM, you must use trampolining, which adds some overhead to every call. So most languages choose fast calls without tail call elimination over slower calls with tail call elimination (i.e., speed over correctness).
Comments
scala doesn't optimize general tail calls, either (only direct tail recursion of final methods). If you want to optimize tail calls on the JVM, you must use trampolining, which adds some overhead to every call. So most languages choose fast calls without tail call elimination over slower calls with tail call elimination (i.e., speed over correctness).
Support for tail calls pretty much depends on the actual runtime implementation.
If it is important to you (it certainly is to me), use an implementation which supports proper tail calls.
I'm doing it and I have never looked back.
Out of curiosity, which implementation are you using?
Have a look at http://oss.readytalk.com/avian/.
This is very cool. Thank you!