From: Yusuke ENDOH Date: 2008-12-04T22:39:54+09:00 Subject: [ruby-core:20307] Re: Tail recursion? Hi, 2008/12/4 Robert Dober : > Hi list > > I was just having some real fun with the 191p2 and somehow I was sure > that tail recursion would be optimized away, but alas.... > I than searched the list for any information on that and did not find anything. > Did I only dream or am I correct in assuming that Ruby1.9 will > eventually optimize tail recursions? YARV itself implements tail call optimization, but the feature is currently disabled by default. I guess this is because, if it is enabled, - stack trace will change (and become harder to read), and - set_trace_func cannot hook an event of method return. But I also want tail call optimization in some cases. I think a new method call syntax or feature may be needed to declare that the call is tail call and should be optimized. For example, how about Method#tail_call: def foo ... method(:foo).tail_call end -- Yusuke ENDOH