comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: graphs in ada (combining two generic units referencing each other)
Date: 02 Aug 2002 13:45:19 -0400
Date: 2002-08-02T17:53:48+00:00	[thread overview]
Message-ID: <u65yt889c.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 3d494242$0$18838$91cee783@newsreader01.highway.telekom.at

"Herwig Lejsek" <herwig.lejsek@gmx.at> writes:

> Hello!
> 
> I've some problems programming graphs in ada.
> I've declared two generic Units one called simple_node(describing the type
> node) and one called simple arc(describing the type arc).
> However I need to have type arc to instantiate type node (because of
> adjacent lists) and I need to have type node to instantiate type arc (to
> define which node the arc is pointing to). But when I want to use both
> packages I have to instantiate one first needing the type of the second
> generic unit.
> 
> Is there any possibility to describe a graph in such a way or do have to
> work around keeping nodes and arcs in one generic unit?

This is a typical problem. The Ada solution is to declare the two
types in the same package. You can either just merge the two packages
you have, or move the base type declarations into a third package.

Another option is to use an Ada extension. GNAT provides the Ada
extension "with type" that lets you keep your current two packages.
This particular extension will probably _not_ make it into the next
Ada revision, but something similar to it probably will, so it's not
too bad to use it. It does restrict you to GNAT.

-- 
-- Stephe



      parent reply	other threads:[~2002-08-02 17:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-01 14:17 graphs in ada (combining two generic units referencing each other) Herwig Lejsek
2002-08-01 17:05 ` Frank J. Lhota
2002-08-02 17:45 ` Stephen Leake [this message]
replies disabled

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