3 ms·
Tail call optimization https://mail.mozilla.org/pipermail/rust-dev/2013-April/003557.html https://mail.mozilla.org/pipermail/rust-dev/2013-April/00355... http
by riquito 11y ago
Tail call optimization
https://mail.mozilla.org/pipermail/rust-dev/2013-April/003557.html https://mail.mozilla.org/pipermail/rust-dev/2013-April/00355...
https://github.com/rust-lang/rust/issues/217 https://github.com/rust-lang/rust/issues/217
> I'm sorry to be saying all this, and it is with a heavy heart, but we
tried and did not find a way to make the tradeoffs associated with them
sum up to an argument for inclusion in rust.
> -Graydon
- steveklabnik 11y agoNote that a lot has changed since April of 2013. Rust does have TCO, we just can't guarantee it. And, LLVM has come a long way, so we probably can support guaranteed TCO now, and have 'become' as a reserved keyword for this purpose. https://github.com/rust-lang/rfcs/issues/271 https://github.com/rust-lang/rfcs/issues/271 is a better link today.
- riquito 11y agoThat's really a good news! Thank you for pointing that out.
- hamstergene 11y agoI praise the idea of making TCO explicit and guaranteed, but wonder if whole new keyword is necessary? It could be avoided by modifying `return` with another keyword which is currently impossible at that place, for example return as foobar(x, n-1) return in foobar(x, n-1) override return foobar(x, n-1) final return foobar(x, n-1) It's a little surprising to see entirely new construct invented for something that is just a different implementation of `return`, after all, the end result of computation with tail-return is the same as with normal return, only performance differs.
- steveklabnik 11y agoIn theory, we could have done that too, and I guess we still could.