6 ms·
I don’t know much Clojure, but I thought that lack of TCO was not a problem because you can just manually add `recur` (http://clojure.org/special_forms#Special%
by roryokane 13y ago
I don’t know much Clojure, but I thought that lack of TCO was not a problem because you can just manually add `recur` (http://clojure.org/special_forms#Special%20Forms--%28recur%20exprs*%29 http://clojure.org/special_forms#Special%20Forms--%28recur%2...) when you need it. Are there situations where `recur` doesn’t work but tail-call optimization would help?
- takeoutweight 13y agoIn my talk I use a finite state machine as an example of something that can really benefit from proper tail calls. In this case, the difference between proper tail calls and loop/recur is the difference between "compiling" the FSM and running the FSM in an interpreter loop.
- moomin 13y agoThe quick answer is: mutually recursive functions. True TCO doesn't grow the stack when F calls G calls F again.