From: Michael Hagerty <mhagerty@FNOC.NAVY.MIL>
Subject: Readable mutually recursive data structures?
Date: Wed, 2 Nov 1994 10:40:17 PDT
Date: 1994-11-02T10:40:17-07:00 [thread overview]
Message-ID: <9410027838.AA783801617@smtpgw.fnoc.navy.mil> (raw)
A straightforward question, following up on the mutually recursive
data structures thread earlier. But for Ada-83 exclusively...
Given that I have a generic list package which is to be instantiated
using an item of user-specified type as follows:
type node_list_item_t is
record
In_Seg : SegList_p := SegList_p.null_list;
Out_Seg : SegList_p := SegList_p.null_list;
cost : cost_t := (others=>0.0);
ReqAlt : meters := 0.0;
Node_DB : node_t; -- a record having meaning in this context
end record;
package NodeList_p is new Double_Linked_List
(
Item => Node_List_Item_t
);
type Seg_list_item_t is
record
From_Node : NodeList_p := NodeList_p.null_list;
To_Node : NodeList_p := NodeList_p.null_list;
altitude : meters := 0.0;
Seg_DB : seg_t; -- a record having meaning in this context
end record;
package SegList_p is new Double_Linked_List
(
Item => Seg_List_Item_t
);
where the list package is defined as
generic
type Item is private;
package Double_Linked_List is
type List is private;
(snip, snip)
private
type Node;
type List is access Node;
Null_List : constant List := null;
end Double_Linked_List;
The question is, "What is the sequence of declarations in this mutually
recursive data structure that does not use unchecked_conversion and yet
gives clear visibility to a maintenance programmer, if this is possible
at all?" I have previously used unchecked_conversion and this yields a
solution which is less-readable than I would prefer.
It would be simple, but invalid, to just put the incomplete type
type SegList_p;
in front of the first declaration, as subsequent references are not
merely accesses, but require the prior instantiation of a generic.
Technical details: Verdix compiler on a SPARCstation 10 under SunOS
moving to the latest Verdix compiler on a Sun/1000 under Solaris 2.x.
Regards, Mikey
reply other threads:[~1994-11-02 17:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox