3 ms·
We'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-eliminatio
by busterarm 4y ago
We'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...