From: Christoph Date: 2002-02-25T21:23:56+09:00 Subject: Re: inconsistence in class complex "GOTO Kentaro" wrote in .... > In Ruby world, Module forms partialy order, i.e., A < B and B < C Actually this is not true - Module inclusion is not transitive, but Module inclusion is not trying to reinvent Mathematics either ... > implies A < C for any module A,B,C. Now, we have Complex < Numeric > and Numeric < Comparable, therefore Complex < Comparable automatically > even if Complex#<=> would be undefined. > > There are other Ruby-definable strange numeric sets, e.g., Hamilton's > Quotanion, which has four imaginary units. So, Complex isn't only > special. In fact only a tiny minority of `` Ruby-definable strange numeric set'' can be ordered. > > However, undef Complex#<=> and ignoring the fact Complex < Comparable > seems a practical and acceptable option, IMHO. To go rigorous, Sounds reasonable however since we have been living with the strange Complex behavior for ages we might as well stick with it. > Numeric must not include Comparable but Integer, Float and Rational > must include severally. You would run into problems with the coerce framework - I guess you could do it by manipulating Comparable#included ... however implementing this straightforwardly as OrderedNumeric < Numeric ... would be simpler. Another possibility would be the extension of coercion to Comparables. /Christoph