Igor,

You can make the generic formal parameter a private type.  This
allows it to be instantiated with any type for which assignment
and test for equality are predefined.  You would want to have a
set of numeric parameters for the type so you can make it
useful.  For example,

     generic
       type Item is private;
       with function "+" (L, R : Item) return Item is <>;
       -- with similar parameters for all other numeric operators
       with function "<" (L, R : Item) return Boolean is <>;
       -- with similar parameters for other relational operators
       with function Zero_Equivalent return Item;
       with function Tic_First return Item;
       with function Tic_Last return Item;
       -- The preceding functions are useful for numeric and non numeric
       -- instantiations of private types
    package FooFoo is
       -- some stuff for making the package work,
    end FooFoo;

  You might also look at the example using generic formal pacakge parameters
  in my article in the last issue of Ada Letters.

  Richard

Richard Riehle
[log in to unmask]
AdaWorks Software Engineering
Suite 30
2555 Park Boulevard
Palo Alto, CA 94306
(650) 328-1815
FAX  328-1112
http://www.adaworks.com

On Mon, 7 Dec 1998, Igor Izvarin wrote:

> Hello to everybody,
>
> I continue to ask questions!
>
> Now I am writing the package working with polynomials:
>
> Package POLYNOMIAL_PACKAGE is
> Type POLYNOMIAL is private;
> Procedure Print(...);
> Procedure Dump(...);
> ...
> private
> ...
> end POLYNOMIAL_PACKAGE;
>
> but I want to use polynomials with integer and floating coefficients. HOW
> CAN I MAKE A GENERIC PACKAGE TO WORK WITH DIFFERENT TYPES OF COEFFICIENTS:
>
> generic
>         type COEFFICIENT is ???????
> package ...
> ...
> end;
>
> Sorry for my stupid questions. I am novice in Ada programming.
>
> Thank you for your time and help!
>
> With best regards, Igor Izvarin.
>