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/07/01 Message-ID: <7lgnku$ps4$1@nnrp1.deja.com>#1/1 X-Deja-AN: 496146213 References: <19990623004221.05877.00000987@ngol05.aol.com> <7krps5$ldb$1@nnrp1.deja.com> <37723E5B.53577638@averstar.com> <7kucc8$jfg$1@nnrp1.deja.com> <3773C090.F177F565@averstar.com> X-Http-Proxy: 1.0 x36.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 Jul 01 21:47:14 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-07-01T00:00:00+00:00 List-Id: In article <3773C090.F177F565@averstar.com>, Tucker Taft wrote: > rcollinson@my-deja.com wrote: > > ... > > 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!!! > > You will need to move all of your type extensions into the (private > part of the) generic spec. > > One way you can accomplish that is to change P.C from > being a child to being a separate generic, with a formal tagged type > as a parameter. E.g.: > > generic > type P_T is tagged private; > --... Other formal params as necessary to make up for not being a child > package P_C is > type T is new P_T with > record > B : integer; > end record; > end P_C; > > with P_C; > generic > package P is > type T is tagged > record > A : integer; > end record; > procedure Dummy; > private > package Child is new P_C(T); > type Nt is new Child.T with null record; > end P; > > package body P is > procedure Dummy is > X : Nt; > begin > null; > end Dummy; > end P; > > -- > -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 > Thanks for the help with this! I used a private child class with private operations to implement the solution. It uses private dispatching which I found to be pretty cool. I made a public class-wide create function that returns a class object the caller can pass to the public operations and unknown to him will dispatch if necessary. Thanks again! Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.