comp.lang.ada
 help / color / mirror / Atom feed
* Generic child units with gnat2.03?
@ 1995-03-25  0:00 fintan
  0 siblings, 0 replies; only message in thread
From: fintan @ 1995-03-25  0:00 UTC (permalink / 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






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-03-25  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-03-25  0:00 Generic child units with gnat2.03? fintan

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