comp.lang.ada
 help / color / mirror / Atom feed
From: smize@news.imagin.net (Samuel Mize)
Subject: Re: Re-exporting features from private packages...
Date: 1997/02/20
Date: 1997-02-20T00:00:00+00:00	[thread overview]
Message-ID: <5ej38k$15m0@prime.imagin.net> (raw)
In-Reply-To: 5dp10k$19h$1@goanna.cs.rmit.edu.au


In article <5dp10k$19h$1@goanna.cs.rmit.edu.au>,
Dale Stanbrough  <dale@goanna.cs.rmit.EDU.AU> wrote:
>If a package
>spec was allowed to 'with' a private package, but only refer to it in
>its private section, it would seem we could have the best of both worlds.

In Ada95, you can do this!  With certain restrictions.

Only a given package can see its private variables or types.  This
lets you reason about the behavior of all subprograms that operate
on such items.  Once you've verified the subprograms in that package,
nothing else can invalidate them.

We'd like to extend a package, without having to recompile or break
other programs using the package.  We would make package Extend as
an extension of package Base, and Extend could see Base's private items.

Extend, in Ada95, would be a "child" package of Base.  Its full name
would be Base.Extend .  This is one intended use of child packages.

However, Ada won't let Extend be a child of more than one package.
This may make it harder to build the system you want, given an
existing set of packages.

>[special syntax to "open" a private part]
> would seem to allow a much more flexible use of
>private packages that would not compromise security.
...
>Are there any reasons why this would not be a good thing?

The unity of a package, and the guarantee that no other will mess
with its private items, makes it *MUCH* easier to maintain, debug,
or extend that package.  (In Ada95, for this purpose, we think of the
package and all its children together.)  We don't have to hunt through
the whole program, seeing if any other code has screwed up the
package's internals.

In fact, Ada was designed to be easier to read and maintain, even if
that made it harder to write.

I work in a team.  If a package I use has changed, I have to recompile.
If I don't have to recompile my code, chances are excellent that
nothing has screwed up the packages it depends on.

If an arbitrary other package could alter the private parts of those
packages, I'd have to watch for bugs due to a "quick fix" by someone
else who *thought* he understood the shared package's design.

Happy coding!

Samuel Mize










      parent reply	other threads:[~1997-02-20  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-11  0:00 Re-exporting features from private packages Dale Stanbrough
1997-02-16  0:00 ` Tucker Taft
1997-02-20  0:00 ` Samuel Mize [this message]
replies disabled

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