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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!princeton!udel!klaiber From: klaiber@udel.EDU (Alexander Klaiber) Newsgroups: comp.lang.ada,comp.lang.misc Subject: HELP needed!! Message-ID: <322@louie.udel.EDU> Date: Tue, 7-Jul-87 19:57:17 EDT Article-I.D.: louie.322 Posted: Tue Jul 7 19:57:17 1987 Date-Received: Fri, 10-Jul-87 06:48:17 EDT Sender: usenet@udel.EDU Reply-To: klaiber@udel.EDU (Alexander Klaiber) Organization: University of Delaware Keywords: cyclic imports, generics Xref: mnetor comp.lang.ada:433 comp.lang.misc:513 List-Id: HELP!!!!! I am doing a high-level comparison of high-level languages and I've run into a severe problem with Ada. What I am trying to do is the following: Assume I have a generic package linked_list that, given some type "item", defines a type "list" which is a list of "item". I want to write a package that defined two types, A and B and operations on these. Now my problem is that both A and B are records and A includes a field of type "list of B" and B includes a field of type "list of A". I want the lists to be handled by the generic linked_list. However, the following obviously doesn't work: package my_package is type A is private; type B is private; package list_of_A is new linked_list(A); -- ** problem ** package list_of_B is new linked_list(B); -- ** problem ** -- operations on A/B and "list of A"/B go here private type A is record xxx : list_of_A.list; end record; type B is record xxx : list_of_B.list; end record; end my_package; My compiler complains about A/B not being fully defined in the generic instantiation of linked_list. As Ada doesn't seem to support cyclic import, I see no way of splitting up this package. Note that I always can define the "list of A/B" explicitly by using type A is record xxx : ptr_to_B_node; end; (other type declarations here) and writing procedures to handle the lists. However, this would (a) prevent me from using the already existing generic package and (b) I would have to include two copies of list-handlers, one for "lists of A" and one for "lists of B". This would make Ada look unnecessarily bad. Any ideas how to work around this problem? P.S. I haven't been programming in Ada all too long, so I may be overlooking the obvious... Alexander Klaiber klaiber@dewey.udel.edu