A new module for performing tail-call elimination

Gregory Ewing greg.ewing at canterbury.ac.nz
Sat Jul 18 18:39:29 EDT 2015


Marko Rauhamaa wrote:
> At any rate, it demonstrates how the idiom has its place in Python.

Perhaps it does, but I think I'd still prefer it to be
explicit.

The call in Marko's example is not actually a tail call
as written. To make it a tail call, a return would need
to be added:

 >       return child.setvalue(keyseq, value, offset + 1)

To someone reading the code, it's not obvious why the
return is there. It looks redundant, and is likely to
get removed by someone who thinks it's a mistake.

Using a dedicated keyword would make it clear that tail
call behaviour is being relied upon, and avoid looking
like a spurious return.

-- 
Greg



More information about the Python-list mailing list