3 ms·
someone should put tail recursion in clojure..
by morphir 17y ago
someone should put tail recursion in clojure..
- hga 17y agoIt's there with e.g. the recur kludge (which some people prefer, instead of the implicit style where if you get the position wrong you blow your stack) and real support is waiting for support in the JVM, which with any luck will happen in the next version of Java.
- rikthevik 17y agoI find clojure's current approach to tail recursion to work very well. Maybe I'm just not functional enough, but I'm not sure why function calls that don't push a stack frame should be done the same way as a regular function call. Doing a tail call explicitly is fine, and seems to work okay. Why is the demand for tail calls so great?
- hga 17y agoIt has a certain elegance and conciseness and having different syntax for recur and the mutual recursion trampoline is perhaps more than inelegant. Every little thing you add to a language makes it that much more difficult to remember and correctly use everything. The closer Clojure stays to Scheme in the Scheme to Common Lisp continuum the better.