In article <43A6EB14.8040509 / atdot.net>, SASADA Koichi  <ko1 / atdot.net> wrote:
>Hi,
>
>This is ruby-dev summary 27761-28026.
>
>----
>[ruby-dev:27871] Numeric and Complex
>
>Matz requested for comments about following problem:
>
>Ruby's Numeric class includes Comparable module.  This is based on
>assumption that values are linear.  However Complex value is not linear.
>Current implementation of Complex#<=> is based on Complex#abs, but
>Complex value is used as Range bound.

So basically, the current method compares the magnitude of the complex numbers 
interpreted to be a vector of two values.  (or in other words, the length of 
the hypotenuse is compared).  Why is that problematic?  Seems like a 
reasonable interpretation.

>
>To solve this problem, Matz proposed following solutions:
>
>* Make new super class of Integer, Float, Rational, etc.
>  New class includes Comparable.
>* All of classes (Integer, Float, Rational) includes Comparable.
>* Change Complex super class other than Numeric.
>* Keeping things as they are.
>
>After active discussion, Matz decided follows:
>
>* undef Complex#<=>
>* add a new method Numeric#scalar?

Well, maybe Complex should be derived from a Vector (in the Mathematical 
sense) class?  Vector 'has' Numeric types.  Not sure if a common base class 
between Vector and Numeric is needed (I think probably not).

A Complex would be a Vector with two Numerics, but people using Vector 
directly could create a vector with any number of Numerics.  So Complex would 
just be a special case of Vector with 2 values and some nice "to_s" 
functionality.

Phil