Subj : Re: When are recursive functions needed? To : comp.programming From : Tatu Portin Date : Tue Oct 04 2005 09:50 am Gene wrote: > This is angels dancing on pins. At a certain level of abstraction, of > course iteration and recursion are the same thing. > > The question author was clearly asking about programming styles in > imperative languages. Recursive in this context means "using self- or > mutually-referential function/procedure calls," and iterative means > "using looping structures." It is certainly always possible to > translate from the former to the latter (and back). > > CPS only hides the mechanism for storing intermediate results. It's > not a priori any more or less "recursive" than a loop and a stack or a > self-referential call. When you compile to code, the RTS will have > either a stack or a heap where closures store the same data as would > have been contained in what you call a "manual stack." > So, in more complex systems recursion is a way of presentation, different from iterative, because both solutions are as much efficient. The problem translates to: "To which extent iterative solution is more efficient than recursive?" By the way, does C89 say anything about how large stack can be? Maximum size of stack would be limiting factor, at least in old (very old) compilers. .