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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,205d1b0b3133678 X-Google-Attributes: gid103376,public From: rcollinson@my-deja.com Subject: Re: Calling generic children from their parent? Date: 1999/06/24 Message-ID: <7kucc8$jfg$1@nnrp1.deja.com>#1/1 X-Deja-AN: 493528061 References: <19990623004221.05877.00000987@ngol05.aol.com> <7krps5$ldb$1@nnrp1.deja.com> <37723E5B.53577638@averstar.com> X-Http-Proxy: 1.0 x43.deja.com:80 (Squid/1.1.22) for client 207.109.1.73 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Thu Jun 24 22:44:27 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.05 [en] (Win95; U ;Nav) via NetCache version NetApp Release 3.2.1: Thu May 21 15:16:48 PDT 1998 Date: 1999-06-24T00:00:00+00:00 List-Id: In article <37723E5B.53577638@averstar.com>, Tucker Taft wrote: > rcollinson@my-deja.com wrote: > > ... > > My problem is that I TRY to instantiate a generic > > child unit inside the body of the parent and it > > will not compile. The text Rendezvous with Ada 95 > > states this is possible on page 337 but I have > > been unable to make it work. (On a slightly > > different subject, why in the example on page 337 > > do they WITH and ELABORATE Generic_Parent.Child in > > the last exerpt?) > > If you can post a small self-contained example with the > accompanying error message you received from the compiler, > I suspect someone could quickly point out the solution to your problem. > > Here is an example that should work: > > generic > package P is > procedure Dummy; > end P; > > generic > package P.C is > type T is null record; > end P.C; > > with P.C; > package body P is > package Child is new P.C; > type NT is new Child.T; > procedure Dummy is > X : NT; > begin > null; > end; > -- ... > end P; > > Note that you normally have to instantiate all ancestors > of a child of a generic before instantiating the child. > However, when inside the parent generic, the name of the > parent generic itself represents the "current instance", > and hence you don't need to instantiate the parent generic inside > itself to be able to instantiate the child. > > > Roger > > -- > -Tucker Taft stt@averstar.com http://www.averstar.com/~stt/ > Technical Director, Distributed IT Solutions (www.averstar.com/tools) > AverStar (formerly Intermetrics, Inc.) Burlington, MA USA > The problem was that I was using a tagged type. Code follows: generic package P is type T is tagged record A : integer; end record; procedure Dummy; end P; generic package P.C is type T is new P.T with record B : integer; end record; end P.C; with P.C; package body P is package Child is new P.C; -- This does not compile. type Nt is new Child.T; procedure Dummy is X : Nt; begin null; end Dummy; end P; -- Compilation error is: -- Child is illegal because the type extension P.Child.T shall not be declared in a generic body if the parent type is declared outside that body. *** Any ideas how to get around this??? Thanks!!! Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.