From: Kevin Bullock Date: 2004-05-18T13:22:20+09:00 Subject: Re: Recursion depth On May 14, 2004, at 4:44 PM, Ceri Storey wrote: > On Sat, May 15, 2004 at 05:20:14AM +0900, Kevin Bullock wrote: >> Why is it that guile can handle such recursion but Ruby can't? Is it >> that guile is implemented with iterative recursion in mind, and so >> optimizes for it better? > > In scheme, iteration is almost always defined as tail-recursion. Ergo, > the interpreter / compiler must be able to transform tail-calls into a > goto-like statement, so instead of pushing a new stack frame and then > calling the function, the current stack frame is replaced with that of > the called function. > > Sadly, ruby currently doesn't implement this, although I'd expect it'd > be one of those features ear-marked for the RITE VM. > Thanks all. That's about what I expected. It seems as though optimizing tail recursion is something that Ruby ought to do, given that it draws so much other inspiration from functional languages. Pacem in terris / Mir / Shanti / Salaam / Heiwa Kevin R. Bullock