Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.ARPA
Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!csnet-relay.arpa!geoff%boulder.csnet
From: geoff%boulder.csnet@CSNET-RELAY.ARPA (Geoffrey Clemm)
Newsgroups: net.lang.ada
Subject: Mutually Recursive Data-Structures in ADA
Message-ID: <8509200232.AA03222@UCB-VAX.ARPA>
Date: Tue, 17-Sep-85 22:11:15 EDT
Article-I.D.: UCB-VAX.8509200232.AA03222
Posted: Tue Sep 17 22:11:15 1985
Date-Received: Sat, 21-Sep-85 03:45:57 EDT
Sender: gusella@ucbvax.ARPA
Organization: The ARPA Internet
Lines: 58

I posted this on csnet a couple of times a while back and received no
significant response.  It was suggested that I send it directly to
info-ada@eclb.  If there is a better alternative solution to the one
I am using, I would be very interested in hearing about it.

---------------------------------------------------------------------

From postnews Sun Jul  7 17:19:36 1985
Subject: Implementing mutually dependent access types in separate packages
Newsgroups: net.lang.ada
Distribution: net

*

Problem :
   I have a large program with data structures whose implementations
   are all mutually dependent.  For example, a "FileHeader" is a structure
   containing a field that is a pointer to a "Parameter", a "Parameter" is a
   structure containing a field that is a pointer to an "Item", and an "Item"
   is a structure containing a field that is a pointer back to a "FileHeader".
   (For a simple example, see section 3.8.1 of the ADA standard).
   
   The desireable implementation would consist of one package for each data
   structure, where a package performs the usual data abstraction principle
   of providing accessing functions while hiding the physical implementation
   of the data structure.

   In the above example, the package for "FileHeader" must provide (amoung
   other things) the type "FileHeaderPtr" (ACCESS FileHeader) and an accessing
   function "FileHeader_Parameter" that takes a FileHeaderPtr as an input
   argument and returns a ParameterPtr.  Similarly for each of the other
   packages.

   Unfortunately, I can find no way of doing this in ADA.  The obvious
   implementation generates a "USE" cycle that is illegal according to
   the language standard (not to mention being rejected by our compiler).

   The only method I can discover for doing this in ADA is to take all
   of the data structure definitions out of their respective packages
   and then clump them together into a single "implementation package".
   All the individual packages then "USE" this implementation package.

   This is very unfortunate for a variety of reasons.  Not the least of
   these is that unless the ADA compiler is very smart (which ours isn't),
   changing the implementation of any data structure causes the re-compilation
   of all the data structures that USE the implementation package.

Question :
   Can anyone come up with a way of leaving the implementation of each
   data structure in its own package, while providing the desired accessing
   functions and not violating the ADA standard ?

Note:
   If one was not required to provide accessing functions of the form
   "FileHeader_Parameter(FileHeaderPtr) RETURN ParameterPtr", there of
   course would be no problem, but these accessing functions are critical.

Geoffrey Clemm