From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: Uncle
Date: 1998/05/17
Date: 1998-05-17T00:00:00+00:00 [thread overview]
Message-ID: <Pine.BSF.3.96.980517153518.12746A-100000@shell5.ba.best.com> (raw)
In-Reply-To: 6jlk5s$mob@tomquartz.niestu.com
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
next prev parent reply other threads:[~1998-05-17 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-05-17 0:00 Uncle Chip Richards
1998-05-17 0:00 ` Brian Rogoff [this message]
1998-05-24 0:00 ` Uncle Matthew Heaney
1998-05-25 0:00 ` Uncle Brian Rogoff
1998-05-24 0:00 ` Uncle Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox