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,d7888dd6424b687 X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: Uncle Date: 1998/05/17 Message-ID: #1/1 X-Deja-AN: 354130540 References: <6jlk5s$mob@tomquartz.niestu.com> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: 895445860 2879 bpr 206.184.139.132 Newsgroups: comp.lang.ada Date: 1998-05-17T00:00:00+00:00 List-Id: On 17 May 1998, Chip Richards wrote: > On to specific questions. First, there's an Object type (a tagged record--an > *abstract private* tagged record at the moment, because that seemed like the > right thing to do), from which about half the various widget types are > derived, and a Composite type (called "puInterface" in the original code) > which is derived from Object, and from which the rest of the widgets are > derived. Composite adds a pointer to a list of child Object items, and each > Object contains a pointer to its parent Composite. Since the two types are > interdependent in this way, they must be declared in the same package spec, > right? No other choice? So my urge to make Composites a child package off > Objects is misguided? One way out of this bind is to create dummy parent tagged types for the tagged types involved in the mutual dependency, and then defining your original classes in terms of those dummy types. In your case, package Object_Refs is type Object_Parent_Type is abstract tagged null record; type Object_Ref_Type is access all Object_Parent_Type'Class; end Object_Refs; package Composite_Refs is type Composite_Parent_Type is abstract tagged null record; type Composite_Ref_Type is access all Composite_Parent_Type'Class; end Composite_Refs; package Composites type Composite_Type is new Composite_Parent_Type with private; function Add_To_List(C : Composite_Type; O_Ref : Object_Ref_Type); end Composites; package Objects type Object_Type is new Object_Parent_Type with private; function Get_Container(O : Object_Type) return Composite_Ref_Type; end Composites; You might also want to take a look at John Volan's web page http://www.bluemarble.net/~jvolan/WithingProblem/FAQ.html on the topic of handling mutual dependencies in Ada. -- Brian