Possibly Pythonic Tail Call Optimization (TCO/TRE)
rosuav at gmail.com
Tue Jul 14 19:52:58 CEST 2015
On Wed, Jul 15, 2015 at 3:43 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> I don't like the way integer overflows are explicitly undefined in
> modern C.
> Similarly, I don't like the way tail call behavior is undefined in
Where in the Python spec is it stated that tail call behaviour is
undefined? The behaviour of the 'return' statement is well defined: it
evaluates its expression (or None), *then* removes the top of the call
stack and passes control back to the caller:
This implies that during the evaluation of its expression, the current
function's call stack entry is still present. Tail call behaviour is
therefore well defined: it is identical to any other expression
evaluation, and then the final result is passed back to the caller.
More information about the Python-list