3 ms·
It seems like part of decision was reached because of limitations in LLVM[1]. This makes me a bit uneasy, but I guess it has to follow C to meet its goals. 1)
by protomyth 14y ago
It seems like part of decision was reached because of limitations in LLVM[1]. This makes me a bit uneasy, but I guess it has to follow C to meet its goals.
1) "LLVM does support tail call optimization, but it requires using a different calling convention than C and slowing down all function calls" from https://mail.mozilla.org/pipermail/rust-dev/2013-April/003556.html https://mail.mozilla.org/pipermail/rust-dev/2013-April/00355... and http://llvm.org/docs/CodeGenerator.html#tail-call-optimization http://llvm.org/docs/CodeGenerator.html#tail-call-optimizati...
- deleted 14y ago[deleted]
- cwzwarich 14y agoThey could also add their own calling convention to LLVM to support what they want like GHC and HiPE have done.
- saidajigumi 14y agoNo they can't, at least not without compromising on several points laid out in TFA. Mainly these two: - Tail calls also "play badly" with assumptions in C tools, including platform ABIs and dynamic linking. - Tail calls require a calling convention that is a performance hit relative to the C convention. See other posts in this discussion for examples of the impacts of some alternate calling convention choices.
- anonymous 14y agoThen how can GCC and clang do TCE in C programs?
- aidenn0 14y ago1) They can't do it all the time 2) Some of the times they can do it, they do it when they control both the caller and the callee. In that case you can violate the ABI to your heart's content. 3) I don't really see TCE as an issue in Rust, since they seem to be going the RAII route and, as others have commented, RAII and TCE don't play well together (for the same reason a call at the end of a dynamic binding can't be TCE'd in common-lisp).