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,deae7835ba212732,start X-Google-Attributes: gid103376,public From: dgibson@snoopy.cis.ohio-state.edu (david scott gibson) Subject: Q. about generic child unit instantiation Date: 1996/06/25 Message-ID: <4qq38lINN641@snoopy.cis.ohio-state.edu>#1/1 X-Deja-AN: 162183614 organization: The Ohio State University, Department of Computer and Information Science newsgroups: comp.lang.ada Date: 1996-06-25T00:00:00+00:00 List-Id: Hi. I have a question about generic child units. I would like to have a generic parent package with two generic child units. In one of the generic child units, I would like to create an instance of its sibling unit. However, in order to instantiate the sibling, I need to instantiate the parent unit which doesn't seem to be legal (inside one of its child units). Does anyone know of a way I can instantiate a generic child unit of a generic parent inside of its sibling? Here's an example: P[P_Item] / \ / \ PC2[P_Item] P.C1[C_Item] P.C2[] I would like to instantiate P.C1 inside of P.C2 achieving the effect of PC2 (which is not in the child unit hierarchy). In this scheme, C1 and C2 provide (non-dispatching) implementations of the abstraction in P. The purpose of C2 is to provide C1's implementation of P but with parameter C_Item fixed. The only problem with PC2 (assuming it works) is that it doesn't follow the parent:child :: abstraction:implemenation pattern I'd like to use. -- Dave dgibson@cis.ohio-state.edu -------------------------------------------------- -- PACKAGE P generic type P_Item is private; package P is type T is abstract tagged null record; procedure Op1(x:T; y:P_Item) is abstract; end P; -------------------------------------------------- -- PACKAGE P.C1[C_Item] generic type C_Item is private; package P.C1 is type T is new P.T with private; procedure Op1(x:T; y:P_Item); private type T is new P.T with record rep: Integer; end record; end P.C1; -------------------------------------------------- -- PACKAGE P.C2[] with P.C1; generic package P.C2 is type T is new P.T with private; procedure Op1(x:T; y:P_Item); private -- I cannot instantiate P here. package P_C1_Integer is new -- This doesn't work, but shows P.C1(C_Item => Integer); -- to what I would like to do type T is new P.T with record rep: P_C1_Integer.T; end record; end P.C2; -------------------------------------------------- -- PACKAGE P_C2[P_Item] with P.C1; generic type P_Item is private; package P_C2 is package PI is new P(P_Item => P_Item); package PI_C1_Integer is new PI.C1(C_Item => Integer); type T is new PI_C1_Integer.T with null record; end P_C2;