Hacker News new | ask | show | jobs
by cryptonector 334 days ago
> if your code actually depends on TCE for correct execution, that code might exhaust the stack under ordinary interpreter/compiler settings

But Lisp programmers tend to use recursion for iteration and very much count on TCO. So it really has to be implemented, and the language should require it.

1 comments

Counting on TCO is more of a Scheme thing (where the language spec guarantees it) than a Common Lisp thing. CL does not guarantee TCO so, at least historically, looping (various forms, not just the LOOP facility) was quite common.
As u/dapperdrake points out just below one can use code-walking macros to rewrite recursion into iteration, and Doug Hoyte shows how to do that (specifically for named-let) in Let Over Lambda, thus allowing the illusion of TCO. But IMO just about every language ought to have TCO.