[Python-ideas] A Continuations Compromise in Python

John Graham john.a.graham at gmail.com
Wed May 6 01:28:03 CEST 2009


> I think that a trampoline decorator is an acceptable substitute for
> new syntax that indicates that a call is a tail call and should be
> optimized as such.
>
> I'm still thinking about whether or not such a syntax is an acceptable
> replacement for real TCO. Part of me says that explicit is better than
> implicit, so having a programmer say "I believe this is a tail call"
> and having the compiler flag them is better than having a system where
> adding a comma can cause non-trivial changes in the semantics of the
> code. On the other hand, another part believes that the benefits of
> using an compiler are that the programmer shouldn't have to worry
> about such optimizations, and should always get the benefit of them. I
> think the former is going to win out, because if you're in a situation
> where you have to have TCO, you have to take care to make sure you
> write proper tail calls anyway.
>

I think it's best not to even think of it as an 'optimization', but
rather just a different model of computing that the programmer would
obviously need to know about.  It changes too much behind the scenes
to be 'just' an optimization in many people's eyes.

-JG

ps. work & school but i'll give you some raw code use cases eventually.



More information about the Python-ideas mailing list