From: geoff@boulder.UUCP (Geoffrey M. Clemm)
Subject: Implementing mutually dependent access types in separate packages
Date: Sun, 7-Jul-85 19:19:39 EDT [thread overview]
Date: Sun Jul 7 19:19:39 1985
Message-ID: <383@boulder.UUCP> (raw)
*
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
next reply other threads:[~1985-07-07 23:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1985-07-07 23:19 Geoffrey M. Clemm [this message]
1985-07-08 1:19 ` Implementing mutually dependent access types in separate packages Geoffrey M. Clemm
1985-07-11 17:52 ` Mark Biggar
1985-08-09 18:07 ` Geoffrey M. Clemm
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox