Hacker News new | ask | show | jobs
by EdwardDiego 3938 days ago
You can use the recur special form to enforce recursion from the tail position in Clojure.
2 comments

True, but that's not TCO (or tail call elimination). That would mean that every single tail call is optimized to eliminate that stack overhead.

    (defun foo () (foo)) ;<- tail call

    (defun bar () (bar)) ;<- tail call

    (defun baz (a b) (+  ;<- tail call
                        (* a 2)
                        (* b 3)))
This.