News for hackers. Stuff that matters.
Re:Learning Go by porting a medium-sized web back end from P... by rbobrowicz on Thursday November 09, 2017 @11:26AM (#15663675)
>Tail Recursion

Interesting. I thought the lack of proper tail recursion is a JVM limitation. Hence why Clojure uses loop/recur to handle it by translating it to a loop rather then as an actual tail call. Which means things like mutually recursive functions are not possible in Clojure without blowing the stack.

How does Kotlin handle that? Is it internally rewriting to a loop or trampoline, or did they find some way to actually make proper tail calls?

Re:Learning Go by porting a medium-sized web back end from P... by calcifer on Thursday November 09, 2017 @05:40PM (#15666385)
> Is it internally rewriting to a loop

Yes. You add a `tailrec` modifier to your function. The compiler then checks if the last op in the function is a call to itself. If it is, it gets replaced with a loop. If not, you get a warning that `tailrec` is ignored.