From: Joost Diepenmaat Date: 2008-08-30T05:20:08+09:00 Subject: Re: Does Ruby optimize tail-call recursion? Patrick Li writes: > Hi, > I'm wondering if Ruby 1.9 optimizes tail-call recursion? > I've read some reports that say yes, and some that say no. Does anyone > know? I just compiled the ruby svn trunk with all defaults: ./ruby -v ruby 1.9.0 (2008-08-30 revision 18932) [i686-linux] ./ruby -e 'def bla(); bla(); end; bla()' -e:1:in `bla': stack level too deep (SystemStackError) from -e:1:in `bla' from -e:1:in `bla' from -e:1:in `bla' from -e:1:in `bla' from -e:1:in `bla' from -e:1:in `bla' from -e:1:in `bla' from -e:1:in `bla' ... 7692 levels... from -e:1:in `bla' from -e:1:in `bla' from -e:1:in `bla' from -e:1:in `
' So I guess the answer is: no, it does not optimize tail calls. -- Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/