comp.lang.ada
 help / color / mirror / Atom feed
From: "Antonio Dur�n Dom�nguez" <andudo@teleline.es>
Subject: RE: package dependence question
Date: 2000/05/29
Date: 2000-05-29T00:00:00+00:00	[thread overview]
Message-ID: <wFpY4.9563$K4.60626@telenews.teleline.es> (raw)
In-Reply-To: 8gt19i$1cm8@r02n01.cac.psu.edu

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2431 bytes --]

There are different forms for aproaching to the solution. I think the most
flexible is
the object oriented way so that the nodes of the tree are classes (tagged
types) that
inherit from a common class. This provides flexibility (new classes are
easily added) and
separates the tree handling from tree-node handling.

Another approach could be using a variant record to hold the node
information and a
single access type to handle the tree links. This is pretty much Ada 83
style but has the limitation that
the types of nodes must be known at compile time and new types of nodes are
not
easily incorporated to the code.

Carl Banks <oaf@psu.edu> escribi� en el mensaje de noticias
8gt19i$1cm8@r02n01.cac.psu.edu...
> Okay, when I program, I like to construct large, dynamic tree
> structures.  I like my trees to be traversible in any direction, so if
> you're sitting on a node, you can access its parent or any of its
> branches.
>
> So let's say that a particular tree has a different type of node at
> each level.  For example, type A is the root of the tree.  Its
> branches are of type B.  B's branches are of type C, and so on.
>
> Let's also say that A, B, and C are not really similar (they are only
> similar in that they are in the same tree structure, but bear no
> internal resemblance to each other).  A, B, and C really belong in
> separate packages.
>
> However, packages can't with each other, meaning that types A and B
> can't store access types to each other if they are defined in separate
> packages.  It seems that I have to choose between making the tree
> traversible in only one direction, or defining A, B, and C in the same
> package.
>
> The best solution I could come up with myself is to make A, B, and C
> child packages of a package such as Node, and declaring the types A,
> B, and C (and their access types) in the Node package, while declaring
> functions and procedures in the child packages Node.A, Node.B, and
> Node.C.  This is somewhat messy, as it leaves the fields of type A
> open to package Node.B, but at least it isolates the functions and
> procedures.
>
> My question is, is there a better way to define such a doubly-
> traversible tree, so that different node types need not be defined in
> the same package?
>
> Thanks.
>
>
> --
>         ___\___         ____\___
>     \  /      .\    \  /       .\
>     |><  Carl  <    |><  Banks  <
>     /  \_____)_/    /  \______)_/






  parent reply	other threads:[~2000-05-29  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-29  0:00 package dependence question Carl Banks
2000-05-29  0:00 ` Jeff Carter
2000-05-29  0:00   ` Ray Blaak
2000-05-29  0:00 ` Antonio Dur�n Dom�nguez [this message]
2000-06-03  0:00   ` Robert I. Eachus
2000-05-29  0:00 ` Robert Dewar
2000-05-30  0:00 ` Robert A Duff
2000-05-30  0:00   ` Brian Rogoff
2000-05-30  0:00   ` Ray Blaak
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox