4 ms·
Could this trick be used by ABCL (a Common Lisp implementation on the JVM) to allow for tail-call optimization?
by servytor 5y ago
Could this trick be used by ABCL (a Common Lisp implementation on the JVM) to allow for tail-call optimization?
- runevault 5y agoShould be able to. Clojure used trampolines for tail recursion at least.
- servytor 5y agoBut Clojure uses 'recur' because you cannot modify the stack in the JVM (at least to my knowledge that is the issue with the JVM and TCO).
- runevault 5y agoRight and it uses a trampoline under the hood.
- pflanze 5y agoSince "recur" only allows to recurse to the closest recursion point (a loop or the enclosing function definition), what if it just used JVM's "goto"? Or, if the JVM didn't have a goto, but any kind of iteration construct, used that instead? Then it doesn't have to use a custom stack or allocate anything on the heap.