I know Rust has had some RFCs about the subject. I know there is even a reserved keyword become for explicit tail call elimination. However, the implementation of TCO/TCE seems to be held back. I have read some topics and I understood Rust does not have TCE because of calling conventions. Wouldn't LLVM's tail call instruction solve this?
I have to confess reading "functional features" in descriptions about Rust while Rust not having proper recursion support makes me sad.
EDIT:
Wouldn't LLVM's tail call instruction solve this?
I have been reading. No. In fact, it is the cause of limitation. Still, there should be a way of making unbounded tail recursion.
I think the main reason there hasn't been a big push for tail call optimisation is just Rust's iterators are already really well designed, and most places you'd typically use recursion in a functional language can be written using iterators just as easily.
My interpretation of "functional features" is that Rust feels very much like a functional language (i.e. functions as first-class citizens and ubiquitous use of higher-order functions like map) and it lets you express yourself using a functional style when you want to. Whether TCO is a fundamental part of being "functional" is more of a philosophical argument though.
If you feel like the Rust language would benefit from having native support for tail call optimisation, then there's no reason why you can't revisit an old RFC (or write your own) and champion the feature. You may get more feedback on the internals forum, seeing as most discussion on the actual language and toolchain takes place there.
I actually have wrote a trampoline some time ago. However, I used thunks and I don't feel good writing code using that. In both cases the result is pretty verbose.
The problem with your example is that it does not work with mutual tail recursion, which is the main reason for us to have TCO. I think the only way of handling this is using thunks. Also, converting manually simple recursion into a loop has a pretty readable result, but converting mutual recursion to a loop leads us to a very-big-hard-to-read single function.
Iterators can handle only simple recursion. It is harder to convert mutual recursion into an iterator.
Converting manually simple recursion into a loop has a pretty readable result, but converting mutual recursion to a loop leads us to a very-big-hard-to-read single function.