Skip to content

Comment on One Major Difference Between Clojure and Common Lispparent

Comments

You can use the recur special form to enforce recursion from the tail position in Clojure.

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.