News for hackers. Stuff that matters.
Re:Rust will likely not support tail call optimization by pcwalton on Wednesday April 10, 2013 @02:26PM (#5527015)
Note that we do sibling call optimization per LLVM, and you can use trampolines like Clojure does. Sibling call optimization, most notably, includes all self-calls. This means that calls to the currently executing function in tail position will be tail call optimized, if there are no destructors in scope.

The biggest problem here is ABIs: you have to use Pascal calling conventions instead of C calling conventions. It's also difficult when you have destructors: there are not many tail call positions when destructors are in scope.

Re:Rust will likely not support tail call optimization by tsewlliw on Wednesday April 10, 2013 @02:58PM (#5527259)
I'd vote getting to use RAII is a better win than TCO.

And really its by definition not a tail call when you have to run destructors after a "tail" call, and tricky/annoying to express that destructors should be run prior to a tail call.

Re:Rust will likely not support tail call optimization by masklinn on Wednesday April 10, 2013 @03:25PM (#5527462)
Wouldn't it be possible to have some sort of macro able to "manually" convert calls in a recursive style into loops? Something along the lines of Clojure's `loop/recur` but less tricky (and maybe with a single "word")?
Re:Rust will likely not support tail call optimization by ufo on Wednesday April 10, 2013 @05:30PM (#5528332)
Self recursion is only a particular case and you can often represent it with loops or folding patterns as you are imagining. However, the really cool use for tail call elimination is when you are calling other functions since you can't rewrite the code without breaking encapsulation. Out of the top of my head, one important example of this would be continuation passing style (you need TCO to turn the continuations into real "gotos")
Re:Rust will likely not support tail call optimization by gngeal on Wednesday April 10, 2013 @07:13PM (#5528838)
That would be useless. I believe the point of proper tail calls is that the set of functions that may be called from a particular call site is not closed. The callee may be a parameter of the caller, for example in combinator-style libraries. You can't convert that in advance.
Re:Rust will likely not support tail call optimization by pcwalton on Wednesday April 10, 2013 @04:11PM (#5527804)
Yes, I think so.
Re:Rust will likely not support tail call optimization by edwintorok on Wednesday April 10, 2013 @03:09PM (#5527331)
How about the other two calling conventions that support tail call optimization? (cc 10 and cc11) Do those have the same performance penalty as fastcall + tailcallopt?