News for hackers. Stuff that matters.
Re:ChrysaLisp by holtalanm on Monday January 13, 2020 @11:16AM (#22035692)
don't they get around that by compiling the tailrec to bytecode as a while loop?

other languages supporting tail recursion on the jvm do that. I don't know enough about clojure to say that is how they do it, though.

Re:ChrysaLisp by DannyB2 on Monday January 13, 2020 @05:15PM (#22039320)
Tail calls aren't just for loops. Tail calls can be across functions.

A calls B calls C calls A calls B ... repeat until ... one of the functions solves the problem and does a return. Then the stack is unwound. But with TCO all of the tail calls simply re-use the current stack frame and JUMP to the next function.

Re:ChrysaLisp by lvh on Monday January 13, 2020 @11:31AM (#22035842)
Yes, but you have to be explicit that it's a recur by using the recur special form. (I'm not convinced that matters, but some people get hung up on it.)
Re:ChrysaLisp by holtalanm on Monday January 13, 2020 @02:10PM (#22037521)
yeah, there is special syntax for it in other jvm languages that support tail recursion, as well (kotlin).

i honestly don't know how they would do it otherwise, really. I actually liked the `recur` syntax of clojure when i was playing around with it a few years ago, though.

Re:ChrysaLisp by lvh on Tuesday January 14, 2020 @10:48PM (#22051620)
I don't see why the compiler couldn't be aware of the function it's compiling and special-cases that tail recursion; that's what every other compiler does.