3 ms·
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 tra
by fhars 14y ago
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).
- happy_dino 14y agoSupport 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.
- cantankerous 14y agoOut of curiosity, which implementation are you using?
- happy_dino 14y agoHave a look at http://oss.readytalk.com/avian/ http://oss.readytalk.com/avian/.
- cantankerous 14y agoThis is very cool. Thank you!