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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7053b27671c47d60,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-11-03 05:59:28 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!gatech!paladin.american.edu!auvm!FNOC.NAVY.MIL!mhagerty Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU Newsgroups: comp.lang.ada Message-ID: <9410027838.AA783801617@smtpgw.fnoc.navy.mil> Date: Wed, 2 Nov 1994 10:40:17 PDT Sender: Ada programming language From: Michael Hagerty Subject: Readable mutually recursive data structures? Date: 1994-11-02T10:40:17-07:00 List-Id: 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