4 ms·
I really want an IDE that puts a little yellow warning thingy on the screen whenever the compiler can't TCO a function.
by nmrm2 12y ago
I really want an IDE that puts a little yellow warning thingy on the screen whenever the compiler can't TCO a function.
- Zak 12y agoClojure has a form of this in that the 'recur' special form is used for tail-calls and self-calls are used otherwise. Using 'recur' from other than the tail position is a compile-time error. http://clojure.org/special_forms#Special%20Forms--%28recur%20exprs*%29 http://clojure.org/special_forms#Special%20Forms--%28recur%2...
- Elrac 12y agoAs someone who does not (yet) do recursion and looping-by-recursion in his sleep, I deeply appreciate Clojure's hand-holding to make TC situations completely explicit.
- lmm 12y agoScala has something like that (@tailrec makes it an error if the annotated function isn't TCOed), but I find TCO can make the failures worse. StackOverflowError will hit my high-level generic exception handler, retry that task appropriately and eventually fail it out using my normal failure handling. With TCO that thread instead just spins forever.
- denis1 12y agoI know scala has a @tailrec annotation which will fail to compile if the function is not tail recursive.