>>>>> "A" == Andre Nathan <com.br> writes:
A> Why do I get these different errors?
the short answer : you don't want to know.
A> Why does an explicit 'return' or compiling ruby with --enable-pthreads
A> changes the behaviour?
Adding an explicit return, add a function call. This is why ruby detect
quickly the stack overflow. --enable-pthreads modify internally the calls,
and this explain also the difference.
A> Also, I'm really puzzled by this one: if I put the two functions on the
A> *same file*, fact2(1377) (or fact2(842) with '--enable-pthread') will
A> give the following error: "Bignum can't be coerced into Fixnum" instead
A> of the "stack level too deep" one.
When ruby try to convert to a Fixnum it do
# try the conversion
raise "Bignum can't be coerced into Fixnum"
if it detect the stack overflow when it's in the begin..rescue it will
give the error "Bignum can't be coerced into Fixnum".
If it detect the stack overflow outside the begin...rescue it give 'stack
level too deep'
This is the same error, but ruby give 2 different messages (because it's
in a begin...rescue)