comp.lang.ada
 help / color / mirror / Atom feed
* Generic procedures
@ 1997-11-11  0:00 Tobias Ritzau
  1997-11-13  0:00 ` Mats Weber
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Ritzau @ 1997-11-11  0:00 UTC (permalink / raw)



I wonder if it is possible to have a generic procedure in a
package and do some instations in the same spec.

I have written a socket packet and in the package I have
generic put and get procedures. It would be nice if I could
instatiate the procedure with some standard types. Is this
possible?

Tobias Ritzau
Link=F6pings Universitet





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Generic procedures
  1997-11-11  0:00 Generic procedures Tobias Ritzau
@ 1997-11-13  0:00 ` Mats Weber
  0 siblings, 0 replies; 3+ messages in thread
From: Mats Weber @ 1997-11-13  0:00 UTC (permalink / raw)



Tobias Ritzau wrote:

> I wonder if it is possible to have a generic procedure in a
> package and do some instations in the same spec.

It's not directly possible, because you can instantiate only after elaboration
of the generic's body. The following little package shows you how you can work
around the problem.


package p is
   
   generic
   procedure gp;

   procedure p; -- is new gp;

end p;

package body p is
   
   procedure gp is
   begin
      null;
   end gp;

   procedure pi is new gp;

   procedure p renames pi;

end p;




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Generic procedures.
@ 1997-11-14  0:00 Scott Edgerton {81813}
  0 siblings, 0 replies; 3+ messages in thread
From: Scott Edgerton {81813} @ 1997-11-14  0:00 UTC (permalink / raw)



Tobias Ritzau wrote:

> I wonder if it is possible to have a generic procedure in a
> package and do some instations in the same spec.

Generics typically are written to support code reuse.  With that, I
would suggest that you make the generic into a separate unit (outside of
your package)

This way, you can "With" the generic, and instantiate to your liking.


                        Scott

Std Disclaimer:  I speak for myself, not my employer.
_________________________________________________________________
Scott G. Edgerton
Command and Control Systems Dept
Raytheon, Hagar pond
Marlborough, MA




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-11-14  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-11  0:00 Generic procedures Tobias Ritzau
1997-11-13  0:00 ` Mats Weber
  -- strict thread matches above, loose matches on Subject: below --
1997-11-14  0:00 Scott Edgerton {81813}

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