--- Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Tue, 12 Jun 2007 15:51:07 -0700, Steve Howell
> wrote:
>
> >
> > --- "Anders J. Munch" <[EMAIL PROTECTED]> wrote:
> >>
> >> Converting tail-recursion to iteration is
> trivial,
> >> and perfectly reasonable for
> >> a human to do by hand. You add an outer "while
> >> True"-loop, the recursive call
> >> becomes a tuple assignment, and other code paths
> end
> >> with a break out of the
> >> loop. Completely mechanical and the resulting
> code
> >> doesn't even look that bad.
> >>
> >
> > I have to ask the stupid question. If a human can
> do
> > this completely mechanically, why can't a machine?
>
>
> They can and do -- some compilers optimize
> tail-recursion into iteration.
>
> Python doesn't, as a deliberate design decision,
> because to do so would
> lose traceback information.
>
Ok, that didn't occur to me. What does occur to me,
though, is that tracebacks for recursive algorithms
can get kind of, well, recursive, so I wonder if
there's a tradeoff somewhere.
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo!
FareChase.
http://farechase.yahoo.com/
--
http://mail.python.org/mailman/listinfo/python-list