comp.lang.ada
 help / color / mirror / Atom feed
* graphs in ada (combining two generic units referencing each other)
@ 2002-08-01 14:17 Herwig Lejsek
  2002-08-01 17:05 ` Frank J. Lhota
  2002-08-02 17:45 ` Stephen Leake
  0 siblings, 2 replies; 3+ messages in thread
From: Herwig Lejsek @ 2002-08-01 14:17 UTC (permalink / raw)


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?

Ciao,
Herwig






^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: graphs in ada (combining two generic units referencing each other)
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Frank J. Lhota @ 2002-08-01 17:05 UTC (permalink / raw)


Given their tight coupling, perhaps the types simple_node and simple_arc
should be declared in the same generic package.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: graphs in ada (combining two generic units referencing each other)
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Leake @ 2002-08-02 17:45 UTC (permalink / raw)


"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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-02 17:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox