comp.lang.ada
 help / color / mirror / Atom feed
* generic packages
@ 2002-07-09 13:03 Sami Evangelista
  2002-07-09 13:28 ` Fabien Garcia
  2002-07-10  2:00 ` SteveD
  0 siblings, 2 replies; 25+ messages in thread
From: Sami Evangelista @ 2002-07-09 13:03 UTC (permalink / raw)


hello everybody

i have declared a package generic_set like this :
-------------------------------------------------
generic
    type Element is private;
    with function "=" (E1, E2 : in Element) return boolean;
package Generic_Set is
    type Set_Record is private;
    type Set is private;
     .....
private
    type Set is access Set_record;
    type Set_record is record
       El : Element;
       Others_Els : Set;
    end record;
end Generic_Set;
-------------------------------------------------


now i want to declare a generic function which take a A set and return a 
B set according to a function wich take a A element and return B 
element. I have tried this in the generic_set.ads file, but gnat crashes 
(???):
--------------------------------------------------
generic
      with package a_set is new generic_set(<>);
      with package b_set is new generic_set(<>);
      with function a_to_b(A : in a_set.element) return b_set.element;
function a_set_to_b_set(the_set : in a_set.set) return b_set.set;
-------------------------------------------------


is there any solution ?

thanks for any help


Sami Evangelista
sami.evangelista@wanadoo.fr




^ permalink raw reply	[flat|nested] 25+ messages in thread
* Generic Packages
@ 2001-04-19 21:27 Eyal Ben-gal
  2001-04-19 20:26 ` Ehud Lamm
  2001-04-19 22:09 ` Robert A Duff
  0 siblings, 2 replies; 25+ messages in thread
From: Eyal Ben-gal @ 2001-04-19 21:27 UTC (permalink / raw)


I have two packages for implementing a polynom.
In the first package I'm using linked list (PolyList) and the second is an
array (Fixed_Polynom)
both of the packeges supporting the same package interface such as:
"+", "-", SetFirst, SetNext, GetElement,

I've tried to create a generic package which will implement
"*", drivation calculation, print and so on.  (lets call this packes
general_pol) which ofcourse using the SetFirst, SetNext functions

when I'm using general_pol with the decleration of explicit type which will
be the type to use from the abstruct types of the erlier packages there is
no problem,

but when i'm trying to make it generic I fail since I'm calling the abstruct
data type functions and the compiler ofcourse can't know how to connect that
to the type I'm using for the SetFirst, SetNext functions.

How can I do that ?
generic

type Polynom is private

package general_Pol is

function sum (frst :Polynom; scnd :Polynom) return Polynom;

function "*" (first:Polynom; second:Polynom) return Polynom;

function derive (plnm:Polynom) return Polynom;

procedure print (plnm:in out Polynom);

function "=" (first:Polynom; second:Polynom) return boolean;

function SetPolynom return Polynom;

function Count (x:Polynom) return integer;

end general_Pol;



How can I create it Generic that will implement in first instatiation for
PolyList the additional operations,

and later the same for Fixed_Polynom.

Thanks,

        Eyal.






^ permalink raw reply	[flat|nested] 25+ messages in thread
* Generic packages
@ 2000-02-16  0:00 David Olsson
  2000-02-16  0:00 ` R. Tim Coslet
  0 siblings, 1 reply; 25+ messages in thread
From: David Olsson @ 2000-02-16  0:00 UTC (permalink / raw)


If I want to make a generic package with a function as a generic
parameter to the package, and that function returns a value of a
specifik enumeration, so where can I define that enumeration. I can't do
before generic and if I put it between generic and package, than the
compiler thinks its a generic parameter to package and complains that it
should be defined as (<>) or something. If I put it after package, then
it wont be visible for the function. I guess you can put it in a
seperate ads file, but that isn't pretty in my opinion. Is there another
way ?

/David





^ permalink raw reply	[flat|nested] 25+ messages in thread
* Generic Packages
@ 1998-08-10  0:00 Tory Patnoe
  1998-08-11  0:00 ` Robert I. Eachus
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: Tory Patnoe @ 1998-08-10  0:00 UTC (permalink / raw)


Here is a quick question which I was unable to find the answer to in the Ada95 Reference Manual.

I have a program which takes a long time to elaborate.  I am suspecting it has something to do with the generic integer_io.  The
current program (not my design!) looks something like this...

package process1 is
    yada-yada-yada;
    package int_io is new integer_io; use int_io;
end process1;

package process2 is
    more yada-yada-yada;
    package int_io is new integer_io; use int_io;
end process2;

Does the compiler make TWO separate instantiations of int_io in this case?   It would, therefore, make my code larger and take more
time at elaboration?  I suspect this is the case and consequently it would be better to do something like this.

package int_io is new integer_io; use int_io;

with int_io; use int_io;
package process1 is
    yada-yada-yada;
end process1;

with int_io; use int_io;
package process2 is
    more yada-yada-yada;
end process2;

Thanks

Tory




^ permalink raw reply	[flat|nested] 25+ messages in thread
[parent not found: <4inq3c$lr9@NNTP.MsState.Edu>]

end of thread, other threads:[~2002-07-11 20:56 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5e03nm$esq@netty.york.ac.uk>
1997-02-15  0:00 ` Generic Packages Jon S Anthony
1997-02-20  0:00 ` phtruong
1997-02-21  0:00   ` Robert Dewar
1997-02-25  0:00     ` Quorlia
1997-02-27  0:00       ` Robert Dewar
2002-07-09 13:03 generic packages Sami Evangelista
2002-07-09 13:28 ` Fabien Garcia
2002-07-09 13:41   ` Sami Evangelista
2002-07-10  2:00 ` SteveD
2002-07-11 13:41   ` Sami Evangelista
2002-07-11 20:56     ` Adam Beneschan
  -- strict thread matches above, loose matches on Subject: below --
2001-04-19 21:27 Generic Packages Eyal Ben-gal
2001-04-19 20:26 ` Ehud Lamm
2001-04-19 22:09 ` Robert A Duff
2001-04-20  6:50   ` Ehud Lamm
2000-02-16  0:00 Generic packages David Olsson
2000-02-16  0:00 ` R. Tim Coslet
1998-08-10  0:00 Generic Packages Tory Patnoe
1998-08-11  0:00 ` Robert I. Eachus
1998-08-11  0:00 ` Tucker Taft
1998-08-12  0:00 ` Dale Stanbrough
1998-08-17  0:00 ` Dr. Hubert B. Keller
1998-08-27  0:00   ` Simon Wright
     [not found] <4inq3c$lr9@NNTP.MsState.Edu>
1996-03-22  0:00 ` John Herro
1996-03-22  0:00   ` Samuel Tardieu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox