Dave Thomas wrote:
> The following code crashes the interpreter on my Powerbook:
> 
> ruby -r mathn -e 'p((-1/2)**3)'
> 

Actually, it's both worse and better than that:

This crashes the interpreter:

   ruby -I. -rrational -rcomplex -e 'p 2**2'

This doesn't

   ruby -I. -rcomplex -rrational  -e 'p 2**2'

The problem is that rational and complex try to know too much about each 
other. In rational.rb, there's code like:

   if not defined? Complex
     alias power! **;
   end

If class Complex is loaded before class Rational, then everything works.
Class mathn unfortunately loads the two the wrong way around, which is 
why it causes the problem.

Now the strange question is, why does it work on Intel boxes but crash 
on my ppc?


The short-term fix would seem to be to change the order or requires in 
mathn. However, that doesn't solve the underlying problem: rational, 
complex, and mathn seem to be somewhat too coupled.


Cheers


Dave