5 ms·
It can compile to a loop. JVM can't optimize it for free at runtime. Scala has tail recursion elimination
by dustingetz 13y ago
It can compile to a loop. JVM can't optimize it for free at runtime. Scala has tail recursion elimination
- anonymoushn 13y agoPlease, scalac performs TCO in fewer cases than g++. Some JVMs are able to perform TCO, which is nice since scalac won't do it.
- bunderbunder 13y agoWhat about tail calls for mutually recursive functions? My understanding is that Scala is not able to do tail call elimination in this situation. So the only situation where you can be sure that deep recursion won't overflow the stack is when a function is tail calling itself. If Frege isn't able to do any better with mutual recursion then that might be a severe limitation on its utility. Scala users can work around the issue by writing loops manually. In a pure language, not so much.