On 1/17/02 6:35 AM, "Dave Thomas" <Dave / PragmaticProgrammer.com> wrote: > > I was sent the following by Philippe de Rochambeau, but not having a > Mac I can't confirm it: > > > I would like to report a bug report for Ruby 1.6.6 on darwin (MacOSX > 10.1.2). > > The following program makes Ruby crash whenever you use the number > 400. > > # Save this as fact.rb > def fact(n) > if n == 0 > 1 > else > n * fact(n-1) > end > end > print fact(ARGV[0].to_i), "\n" > > > For instance, ruby fact.rb 40 works but ruby fact.rb 400 crashes Ruby. > Now that I finally figured out, with lots of help here, that you *can* set the stack size, this works in the sense of giving reasonable errors: > [dslstat473:~/Documents/Projects] chrisg% ruby fact.rb 400 > fact.rb:5:in `fact': stack level too deep (SystemStackError) > from fact.rb:5:in `fact' > from fact.rb:5:in `fact' > from fact.rb:5:in `fact' > from fact.rb:5:in `fact' > from fact.rb:5:in `fact' > from fact.rb:5:in `fact' > from fact.rb:5:in `fact' > from fact.rb:5:in `fact' > ... 199 levels... > from fact.rb:5:in `fact' > from fact.rb:5:in `fact' > from fact.rb:5:in `fact' > from fact.rb:8 > [dslstat473:~/Documents/Projects] chrisg% -- Every society honors its live conformists and its dead troublemakers. -Mignon McLaughlin, author