From: klaiber@udel.EDU (Alexander Klaiber)
Subject: HELP needed!!
Date: Tue, 7-Jul-87 19:57:17 EDT [thread overview]
Date: Tue Jul 7 19:57:17 1987
Message-ID: <322@louie.udel.EDU> (raw)
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
next reply other threads:[~1987-07-07 23:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1987-07-07 23:57 Alexander Klaiber [this message]
1987-07-10 16:56 ` HELP needed!! stt
1987-07-14 23:41 ` Chris Henrich
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox