From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2e27f5c95ae373a1,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-26 23:39:03 PST Path: nntp.gmd.de!news.rwth-aachen.de!news.rhrz.uni-bonn.de!news.uni-stuttgart.de!rz.uni-karlsruhe.de!xlink.net!howland.reston.ans.net!pipex!lyra.csx.cam.ac.uk!sunsite.doc.ic.ac.uk!unix.sbu.ac.uk!news From: Fintan Culwin Newsgroups: comp.lang.ada Subject: Generic child units with Gnat Date: 27 Mar 1995 07:39:03 GMT Organization: South Bank University Message-ID: <3l5q2n$6le@unix.sbu.ac.uk> NNTP-Posting-Host: culwinf.sbu.ac.uk Date: 1995-03-27T07:39:03+00:00 List-Id: 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