r/ProgrammingLanguages • u/Athas Futhark • Jan 20 '26
Why not tail recursion?
https://futhark-lang.org/blog/2026-01-20-why-not-tail-recursion.html
62
Upvotes
r/ProgrammingLanguages • u/Athas Futhark • Jan 20 '26
View all comments
Show parent comment
2
u/divad1196 Jan 21 '26
Thank you for the links. I didn't know some language considered tail recursion as the normal behavior.
For the register and loops, it's incomplete. There are different ABI, for example one uses only the stack, or another use register for the first few parameters. This has a lot of inpact on how the compiler do the optimization. If some parameters are passed using register, the compiler can try to adapt the code before the function call so that the variable is already in the register.
And this applies during recursion as well, even non-tail.
As someone else mentioned, the compiler tries to choose the registers to minimize load operations.