I came to know about the concept of Tail Call Optimization(TCO) from this blog: Sing Me A Song of Stack Overflow: A Musical Tail Call Optimization.
Going into this concept(or "feature" or "optimization technique"), I came to know that using TCO in python is not a pythonic way as per Guido explains it:
http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.html http://neopythonic.blogspot.com/2009/04/final-words-on-tail-calls.html
Further inspection resulted to finding a blog by James Tauber that discusses about Thunks, Trampolines and Continuation Passing Thunks, Trampolines and Continuation passing by James Tauber.
James Tauber shows how the use of Thunks, Trampolines and Continuation passing to solve the stack call problem of recursive functions, but the explaination is some how hard to grasp.
So, here are some of my queries that I would like to be cleared about:
- Can anyone here provide an understandable explanation to these concepts?
- Is this concept trying to implement TCO in python or is it different from TCO?
- As Guido refers TCO as
not a pythonic way
because TCO does not give proper traceback, does the concept ofThunks, Trampoline and Continuation passing
meet this requirement of preserving the tracebacks?