4 ms·
How does one Lisp without TCO? (Yes, I know some do without, but usually not without a great reason...for example Clojure needing to maintain JVM calling conve
by busterarm 4y ago
How does one Lisp without TCO?
(Yes, I know some do without, but usually not without a great reason...for example Clojure needing to maintain JVM calling conventions)
- capableweb 4y agoOne focuses on the learning aspects rather than creating a production lisp. If you want a production lisp, there are plenty out there. And regardless, adding TCO is relatively simple as well, so not exactly a hard problem to figure out after you've written the first version of your toy lisp.
- busterarm 4y agoWe're talking about Lisp in Python here. Python itself famously[1,2] refuses to have TCO. 1: http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.html http://neopythonic.blogspot.com/2009/04/tail-recursion-elimi... 2: http://neopythonic.blogspot.com/2009/04/final-words-on-tail-calls.html http://neopythonic.blogspot.com/2009/04/final-words-on-tail-...
- Xophmeister 4y agoYou can implement TCO in Python manually with continuation-passing style and trampolines.
- capableweb 4y agoHere is a lisp implementation (mal) with TCO, written in Python: - https://github.com/kanaka/mal/blob/master/impls/python/step5_tco.py https://github.com/kanaka/mal/blob/master/impls/python/step5... - Theory: https://github.com/kanaka/mal/blob/master/process/guide.md#step-5-tail-call-optimization https://github.com/kanaka/mal/blob/master/process/guide.md#s...
- rscho 4y agoScheme guarantees TCO, but not Lisp in general I think. I seem to remember that Common Lisp does not guarantee TCO either.
- arunix 4y agoCommon Lisp does not guarantee it, but a few implementations do provide it https://0branch.com/notes/tco-cl.html https://0branch.com/notes/tco-cl.html
- kazinator 4y agoGenerally, by doing actual work instead of linear recursion exercises.
- fami-com 4y agoCommon Lisp doesn't guarantee TCO, and yet people manage just fine