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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6c2635acbf98f13d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-02 10:51:57 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: graphs in ada (combining two generic units referencing each other) Date: 02 Aug 2002 13:45:19 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <3d494242$0$18838$91cee783@newsreader01.highway.telekom.at> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1028310828 2998 128.183.220.71 (2 Aug 2002 17:53:48 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 2 Aug 2002 17:53:48 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:27619 Date: 2002-08-02T17:53:48+00:00 List-Id: "Herwig Lejsek" 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