Robert Klemme wrote:
> Christophe Grandsire wrote:
> > Selon ChrisH:
> >
> >> Thanks Eric.  I just wonder why Numeric doesn't implement it
> >> properly?
> >
> > Probably because it can't. I'm not completely up-to-date with the
> > Numeric inheritance chain, but I guess for instance Complex numbers
> > also inherit from Numeric. Being Numeric doesn't necessarily mean
> > that there is a meaningful order among the objects.
>
> Although I agree with your analysis that Numeric can't properly implement
> <=> the question remains why <=> is actually implemented in Numeric.  ATM
> I cannot see what necessitates it.  Including Comparable is not a reason
> IMHO because that will break either way (i.e. with missing <=> and with
> incomplete implemented <=>).
>
> > Then again, I'm out on a limb here, and may be completely wrong.
>
> Not completely but I have the feeling we're still not there.  Someone
> probably needs to take the time and have a look at the sources...
>

#-------------
class Roo < Numeric; end

a = Roo.new
b = Roo.new
c = a

p a <=> b  #-> nil
p a <=> c  #-> 0
#-------------

Well, that's helpful!

Ruby (like me) hasn't a clue what a 'Roo' is,
but it's able to tell that a == c which might
be enough to keep a routine running.


<Changelog>
Wed Nov 20 01:52:21 2002  Yukihiro Matsumoto  <matz / ruby-lang.org>

 * numeric.c (num_cmp): added to satisfy Comparable assumption.
</>

http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/numeric.c.diff?r1=1.59;r2=1.60;f=h


daz