From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: Can't hide parts of ADTs in private children
Date: 1998/11/09
Date: 1998-11-09T00:00:00+00:00 [thread overview]
Message-ID: <uemrcoh6c.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 364683EB.41C6@syd.csa.com.au
David Bowerman <davidb@syd.csa.com.au> writes:
> I am implementing an Abstract Data Type (Class) in a package. The code
> goes something like this:
>
> package Class_X_Package is
>
> type Class_X is private;
> type Class_X_Ptr is access Class_X;
>
> ... operations on objects of type X
>
> private
>
> type Class_X is
> record
> Component_A : Type_A;
> Component_B : Type_B;
> ...
> end record;
>
> end Class_X_Package;
>
> The abstract data type (X) is complex, and Type_A, Type_B, etc hide a
> lot of structure within themselves.
> I would like to break the package down further, declare the types, and
> generally hide the details of, Type_A, Type_B, etc (never intended to be
> visible to the client) in private child packages.
Why do Type_A, Type_B belong in child packages, instead of in library
packages? In building an ADT, you can use facilities of a library,
while making it clear that the user of your ADT should not use the
library directly. Unless Type_A depends on something else in
Class_X_Package, just put it in its own library level package.
> But I can't do this because these types are referred to in the private
> part of the parent package spec, and this isn't allowed to 'with' its
> children.
>
> Can anyone suggest another way of doing it.
Alternatively, make Class_X an access type, which allows you to defer
the full type definition to the package body, where you can 'with'
child packages.
-- Stephe
next prev parent reply other threads:[~1998-11-09 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-11-09 0:00 Can't hide parts of ADTs in private children David Bowerman
1998-11-09 0:00 ` Stephen Leake [this message]
1998-11-10 0:00 ` Dale Stanbrough
1998-11-16 0:00 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox