Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Lazy lists in Lua and eliminating tail-calls with continuations (osa1.net)
38 points by shawndumas on July 2, 2012 | hide | past | favorite | 1 comment


The trampoline technique is especially useful when you need both TCO and mutual recursion (and the compiler doesn't support TCO across functions.) This is why 'trampoline' is part of the core library in Clojure.

The language targets JVM, where you seemingly cannot just replace the current stack frame with that of another function, so TCO on mutual recursion in Clojure is done with 'trampoline'. Recursion within the same function is done using a special 'recur' form.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: