3 ms·
Rust doesn't guarantee TCO, but LLVM may decide to do it if it wishes.
by steveklabnik 6y ago
Rust doesn't guarantee TCO, but LLVM may decide to do it if it wishes.
- Gibbon1 6y agoLack of a guarantee says you should use explicit loops.
- majewsky 6y agoThat's assuming the tail call is visible in human-level source code. You could also have a situation where A tail-calls B, B tail-calls C and C tail-calls A. If B and C get inlined, you now have the opportunity to convert A's self-tail-call into a loop. Refactoring A manually may not be desirable, e.g. if inlining B and C cause significant code duplication, or if they live in entirely different libraries.
- heavenlyblue 6y agoThis is obviously a mistake if that happened, are you proposing for the compilers to “fix” this bug automatically until someone changes one of these functions to not do a tail call and it explodes out of the blue?
- majewsky 6y agoWhy would that be a mistake?
- steveklabnik 6y agoI agree. Not sure why you're downvoted.