[Python-Dev] Proper tail recursion

Michael Hudson mwh at python.net
Fri Jul 16 16:04:20 CEST 2004


Christopher T King <squirrel at WPI.EDU> writes:
> On 2004年7月15日, Guido van Rossum wrote:
>>> > How about: Tail recursion "enables" recursion-oriented (functional)
>> > style? :)
>>>> Still -1. I was understating my case: I find the "recursion is the
>> basis of everything" attitude harmful.
>> I think it's still best to "enable" such a style in some cases -- Python's 
> syntax is designed to allow formulation of a problem in the most natural 
> way. Sometimes it's more natural to formulate a problem as a recursive 
> function than a procedural one, but the current implementation restricts 
> this.

I think it's pretty hard to come up with a problem where the natural
solution is tail recursive. There are problems where the natural
solution is *recursive*, sure -- but if the natural recursive solution
is tail recursive, I'd expect the iterative solution to be even more
natural.
Cheers,
mwh
-- 
 NUTRIMAT: That drink was individually tailored to meet your
 personal requirements for nutrition and pleasure.
 ARTHUR: Ah. So I'm a masochist on a diet am I?
 -- The Hitch-Hikers Guide to the Galaxy, Episode 9


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /