comp.lang.ada
 help / color / mirror / Atom feed
* Subprogram access types and generic packages
@ 1997-03-18  0:00 Greg Bond
  1997-03-19  0:00 ` Robert A Duff
  1997-03-20  0:00 ` Tucker Taft
  0 siblings, 2 replies; 3+ messages in thread
From: Greg Bond @ 1997-03-18  0:00 UTC (permalink / raw)



I'm trying to write a generic package that will register an access type
of one of its internal subprograms with an external subprogram when
instantiated. I get the error message:

pkg.adb:12:14: access type must not be outside generic body

Why not? 

Here's a simple bit of code that generates this error: (gnatmake
access_test)

--------------------------------------------------
access_test.adb
--------------------------------------------------

with Pkg;

procedure Access_Test is

   Val: constant Integer := 10;

   package Test is new Pkg (Val);
   use Test;

begin
   null;
end Access_Test;


--------------------------------------------------
pkg.ads
--------------------------------------------------

generic
   Const: Integer;

package Pkg is

   pragma Elaborate_Body (Pkg);

end Pkg;

--------------------------------------------------
pkg.adb
--------------------------------------------------

with Reg; use Reg;

package body Pkg is

   procedure Proc is
   begin
      null;
   end Proc;

begin

   Register (Proc'Access);

end Pkg;

--------------------------------------------------
reg.ads
--------------------------------------------------

package Reg is

   type Proc_Alias is access procedure;

   procedure Register (Proc: Proc_Alias);

end Reg;

--------------------------------------------------
reg.adb
--------------------------------------------------

package body Reg is

   procedure Register (Proc: in Proc_Alias) is
   begin

    null;

   end Register;

end Reg;

--
* Greg Bond                       * Dept. of Electrical and Computer Eng.  
* email: bond@ee.ubc.ca           * Univ. of British Columbia      
* voice: (604) 822 0899           * 2356 Main Mall                 
* fax:   (604) 822 5949           * Vancouver, BC              
* web: http://www.ee.ubc.ca/~bond * Canada, V6T 1Z4                                       





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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-18  0:00 Subprogram access types and generic packages Greg Bond
1997-03-19  0:00 ` Robert A Duff
1997-03-20  0:00 ` Tucker Taft

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