comp.lang.ada
 help / color / mirror / Atom feed
From: Fintan Culwin <fintan@sbu.ac.uk>
Subject: Generic child units with Gnat
Date: 27 Mar 1995 07:39:03 GMT
Date: 1995-03-27T07:39:03+00:00	[thread overview]
Message-ID: <3l5q2n$6le@unix.sbu.ac.uk> (raw)

Regarding the instantation of generic child packages with Gnat 2.03.

Following the example of such instantiations in section 2.8 of the 
Ada 9X rationale. With regard to Gnat insisting upon one compilation 
unit per source code file and the requirement to have generic package 
bodies available at compile time. 

The following files were produced.

====================================================================


-- Filename ComplexNumbers_.ads

generic
   type FloatType is digits <>;
package ComplexNumbers is
   procedure foo( Dummy : in FloatType); 
end ComplexNumbers;

====================================================================

-- filename ComplexNumbers.adb

package body ComplexNumbers is
   procedure foo( Dummy : in FloatType) is
   begin -- foo
      null;
   end foo;
end ComplexNumbers;

====================================================================

-- filename ComplexNumbers.Polar_.ads
generic
package ComplexNumbers.Polar is
   procedure bar( Dummy : in FloatType); 
end ComplexNumbers.Polar;

====================================================================

-- filename ComplexNumbers.Polar.adb

package body ComplexNumbers.Polar is
   procedure bar( Dummy : in FloatType) is
   begin -- bar
      null;
   end bar;
end ComplexNumbers.Polar;

====================================================================

The client program for this parent/child generic package is

====================================================================


01 -- Filename FooBar.adb
02
03 with ComplexNumbers.Polar;
04
05 -- package RealComplexNumbers is new ComplexNumbers( Float);  
06 -- package RealComplexNumbers.Polar is new ComplexNumbers( Float);
07
08 procedure FooBar is
09
10 --   package RealComplexNumbers is new ComplexNumbers( Float);
11 --   package RealComplexNumbers.Polar is 
12 --                                new ComplexNumbers( Float);
13
14 begin -- FooBar
15   null;
16 end FooBar;

The attempted instantiation at line 05 resulted in the error message
 
           'Keyword body expected here' (following package). 

Presumaby as gnat insists upon one compilation unit per file.

With lines 05 and 06 commented out, the alternative instantaition at 
line 10 was successful. But the attempted instantiation on line 11/12
produced the error message...

              'child unit allowed only at library level'

Where is the library level ??
What have I got wrong ??
How does one instantiate generic children in gnat??
help !!

Private e-mail preferred & I will sumarise later ...

fintan

============================================================

Fintan Culwin
Senior Lecturer Software Engineering
South Bank University : London

fintan@sbu.ac.uk






             reply	other threads:[~1995-03-27  7:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-27  7:39 Fintan Culwin [this message]
1995-03-30  0:00 ` Generic child units with Gnat David Weller
1995-03-31  0:00   ` Sean McNeil
1995-04-04  0:00 ` Robert Dewar
replies disabled

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