Possibly Pythonic Tail Call Optimization (TCO/TRE)
Mark Lawrence
breamoreboy at yahoo.co.uk
Wed Jul 15 07:22:30 EDT 2015
On 15/07/2015 10:13, Gregory Ewing wrote:
> Chris Angelico wrote:
>> I'm still interested in the explicit "replace current stack frame with
>> this call" operation. Calling it "goto" seems wrong, as most languages
>> with goto restrict it to _within_ a function,
>
> This just suggests to me is that most language designers
> are not very imaginative. :-)
>
> A tail call *is* a goto. That's how you implement one in
> assembly language -- you write a jump instruction instead
> of a call instruction. The jump doesn't have to be to
> the same function.
>
IIRC the realms of the C setjmp and longjmp. I'm just wondering out
aloud if anybody has ever tried playing with cPython using these, or
whether the code and/or Python itself is just too complex to allow this
to even be tried, let alone succeed.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-list
mailing list