From: Daniel Sheppard Date: 2004-04-02T09:25:09+09:00 Subject: Re: error handling You might want to upgrade to ruby 1.8. I don't believe sqrt is a recursive function any more in 1.8 (but I don't have ruby on the machine I'm writing from at the moment, so I couldn't tell you for sure). > -----Original Message----- > From: Phidippus [mailto:mopthisandthat@hotmail.com] > Sent: Friday, 2 April 2004 2:29 AM > To: ruby-talk ML > Subject: error handling > > > I'm evaluating a function at various values in a for loop. > The function works most of the times (99% of parameter range > I am investigating), but at some values, it gives error like > below and crushes. I guess something wrong with sqrt > function. I'm not going to attempt to show the function here > because it is 1.5Mb. If I evaluate the exact same function in > Maple at the value it crushed in Ruby, it behaves fine. > > Is there any way that when the (sqrt) function crushes, it > gives some sort of error value and go on to evaluating at the > next value without crushing the program? I don't want to > manually restart the program at the next value each time the > program crushes. In R, there is "try" function that can used > for this kind of situation. > > Thank you. > > ##### > /usr/lib/ruby/1.6/complex.rb:82:in `initialize': stack level too deep > (SystemStackError) > from /usr/lib/ruby/1.6/complex.rb:63:in `new' > from /usr/lib/ruby/1.6/complex.rb:63:in `Complex' > from /usr/lib/ruby/1.6/complex.rb:130:in `/' > from /usr/lib/ruby/1.6/mathn.rb:244:in `sqrt' > from /usr/lib/ruby/1.6/mathn.rb:244:in `sqrt' > from /usr/lib/ruby/1.6/mathn.rb:244:in `sqrt' > from /usr/lib/ruby/1.6/mathn.rb:244:in `sqrt' > from /usr/lib/ruby/1.6/mathn.rb:244:in `sqrt' > ... 1461 levels... > from rubyHopf0.rb:17:in `each' > from rubyHopf0.rb:17 > from rubyHopf0.rb:16:in `each' > from rubyHopf0.rb:16 > > ##################################################################################### This email has been scanned by MailMarshal, an email content filter. #####################################################################################