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, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site boulder.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!hao!nbires!boulder!geoff From: geoff@boulder.UUCP (Geoffrey M. Clemm) Newsgroups: net.lang.ada Subject: Implementing mutually dependent access types in separate packages Message-ID: <383@boulder.UUCP> Date: Sun, 7-Jul-85 19:19:39 EDT Article-I.D.: boulder.383 Posted: Sun Jul 7 19:19:39 1985 Date-Received: Thu, 11-Jul-85 04:53:05 EDT Distribution: net Organization: University of Colorado, Boulder List-Id: * 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. It's especially annoying since a variety of languages earlier than ADA allow this form of data abstraction. 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