A new module for performing tail-call elimination

MRAB python at mrabarnett.plus.com
Sat Jul 18 20:19:51 EDT 2015


On 2015-07-18 23:39, Gregory Ewing wrote:
> 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.
>
Of the current reserved words, the choice is between 'continue' and
'pass'.

How clear is:

     continue child.setvalue(keyseq, value, offset + 1)

?

I think the problem is that it reads like it's something to do with
co-routines.



More information about the Python-list mailing list