Hacker News new | ask | show | jobs
by joe_fishfish 1500 days ago
Tail-call optimisation on the JVM is already somewhat supported with an annotation / keyword (depending on language). My understanding is that the project will improve the current implementation, but you'll still need to define when a function is tail-recursive, the compiler won't do it automatically.
1 comments

E.g. Scala provides such an annotation, but that is implemented by rewriting the recursive method to a non-recursive method with a loop.
Isn't that kinda how all TCO works?
First level TCO yes, however the annotation way doesn't work for mutually recursive calls.
to clarity just a tad, the Scala compiler does TCO out of the box and the annotation is added only to check that the method is in fact so optimizable
Unless something changed since 2.0.9 (last time I did anything relevant in Scala), only one level, it isn't clever enough to rewrite mutually recursive calls.

This is rather important, specially when coming from languages like Scheme that have TCO as part of the language specification compliance.