Joshua Juran wrote:
scalar
    number (possibly complex)
        real
            rational
                integer
                    Integer
                    BigInt
                Ratio
            Float
        Complex
        Quaternion
    String
    ...

Trying to fit every problem into a rigid inheritance tree is perhaps the
failure of the strict Class-based Object Oriented paradigm; that is, if
you count multiple inheritance and interfaces as afterthoughts rather
than the intent of Class-based Inheritance.

With reference to this Venn diagram:

http://svn.openfoundry.org/pugs/ext/Perl-MetaModel/docs/number-types.png

Here are the corresponding Rule descriptions; structure stolen from Haskell;

   role Num;
   role Real does Num;
   role Fractional does Num;
   role Integral does Real;
   class Int does Integral;
   class int does Integral;     # unboxed...
   role RealFrac does Real does Fractional;
   class Rational does RealFrac;
   class IntRatio does RealFrac;
   role Floating does Fractional;
   role RealFrac does Floating;
   role RealFloat does RealFrac does Floating;
   class Float does RealFloat;
   class Double does RealFloat;
   class ComplexFloat does Floating;
   class ComplexDouble does Floating;

I would suggest this as a good starting point.  One thing that Haskell
is good at is math.

Sam.

Reply via email to