Hacker News new | ask | show | jobs
by miloignis 1472 days ago
There is, but all control flow is structured and the argument/return address stack is out of your control. You have blocks, loops, and if/else statements. The behavior of a branch instruction differs based on context - in a block, it jumps out of the block, in a loop it jumps to the beginning of the loop.

If you really wanted full tail-call behavior, you would either have to compile every function into the same mega-function in a loop and have some sort of if/else tree, or use trampolines (which would additionally require either storing parameters in memory somewhere or using the same type signature for all functions, since function calls are typed).

Overall, it's not a super great situation for true tail-call elimination. For now, I've implemented limited tail-call elimination for single-function recursive calls (transforming them into an in-function loop), and that's patched things up enough for me to continue working for now until I either need to come up with an optimized trampoline or the tail_call instruction finally gets standardized.

1 comments

Thanks, that is pretty dreadful.
The spec people have been very rude to the Lisp people every time something has been brought up. I'm not going to look up everything that's been written, but here's an example:

https://sourceforge.net/p/sbcl/mailman/message/34821303/

I wouldn't call their responses rude, but they are somewhat dismissive.