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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2e27f5c95ae373a1 X-Google-Attributes: gid103376,public From: dweller@Starbase.NeoSoft.COM (David Weller) Subject: Re: Generic child units with Gnat Date: 1995/03/30 Message-ID: <3le685$l9h@Starbase.NeoSoft.COM>#1/1 X-Deja-AN: 100540654 references: <3l5q2n$6le@unix.sbu.ac.uk> organization: NeoSoft Internet Services +1 713 968 5800 newsgroups: comp.lang.ada Date: 1995-03-30T00:00:00+00:00 List-Id: In article <3l5q2n$6le@unix.sbu.ac.uk>, Fintan Culwin wrote: >[supplied source deleted] >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 ... > I'm posting publicly, since I think a lot of folks would like to know this (and to prevent your mailbox from getting flooded... :-) There were only two small problems: 1) generic package instantiations go inside that package declaration, not before 2) Your child instantion syntax was a little off 3) your filenaming convention was slightly off (to my knowledge, GNAT still requires a specific manner to naming child units) (*Ahem* I'm sure Norm Cohen will point out that I now qualify as the other half of those "three types of people" :-) Instead of going into gory details, I'm posting the corrected source below. It was pretty easy to fix. -- File: complexnumbers.ads generic type FloatType is digits <>; package ComplexNumbers is procedure foo( Dummy : in FloatType); end ComplexNumbers; --File: complexnumbers.adb package body ComplexNumbers is procedure foo( Dummy : in FloatType) is begin -- foo null; end foo; end ComplexNumbers; --File: complexnumbers-polar.ads generic package ComplexNumbers.Polar is procedure bar( Dummy : in FloatType); end ComplexNumbers.Polar; --File: complexnumbers-polar.adb package body ComplexNumbers.Polar is procedure bar( Dummy : in FloatType) is begin -- bar null; end bar; end ComplexNumbers.Polar; --Filename foobar.adb with ComplexNumbers.Polar; -- auto visibility to parent procedure FooBar is package RealComplexNumbers is new ComplexNumbers( Float); package PolarRealComplexNumbers is new RealComplexNumbers.Polar; begin -- FooBar null; end FooBar; -- Frustrated with C, C++, Pascal, Fortran? Ada95 _might_ be for you! For all sorts of interesting Ada95 tidbits, run the command: "finger dweller@starbase.neosoft.com | more" (or e-mail with "finger" as subj.) if u cn rd ths, u r gd enuf to chg to Ada :-)