comp.lang.ada
 help / color / mirror / Atom feed
* Mutually Recursive Data-Structures in ADA
@ 1985-09-18  2:11 Geoffrey Clemm
  1985-09-23 23:30 ` Frank Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Geoffrey Clemm @ 1985-09-18  2:11 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <geoff%boulder.csnet@CSNET-RELAY.ARPA>]

end of thread, other threads:[~1985-09-23 23:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1985-09-18  2:11 Mutually Recursive Data-Structures in ADA Geoffrey Clemm
1985-09-23 23:30 ` Frank Adams
     [not found] <geoff%boulder.csnet@CSNET-RELAY.ARPA>
1985-09-19  5:38 ` Doug Bryan
1985-09-23 15:25   ` Geoffrey M. Clemm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox