Mike > ... add the WITHs up carefully ...

Alan & Carmel Brain > What about the use of renaming to package
                    > (a subset of the resources of) other packages
                    > into one logically related chunk?

Thanks for bringing this up.

I would count a renamed package as a package for the
maintenance metrics, because the maintenance programmer must
use tools to search for both names.

I think using renames to package stuff together and to hide
other stuff is a WONDERFUL technique of software reuse and I
use it a lot.

The problem with renamings of packages is that they only rename
the visible part. The biggest configuration management weakness
is the Ada language is the lack of method of renaming a package body.

By renaming the package spec and body together, as Ada permits,
the programmer is forced to duplicate the package spec for each
package body. This causes a lack of integrity in the copied
package spec because a change in one might not propogate to the others,
and worse: a change in one might not be tested against the others.

Ada-95 introduced a way to have multiple GENERIC package bodies
through abstraction, but not a way to have multiple NONGENERIC
package bodies.

An alternative that would solve the same problem would be a way
to pass a NONGENERIC package as a parameter to a generic package,
which would be the moral equivalent of renaming the package
body, because the compiler would enforce the absolute identity
of the package specification's non-private part.

Another weakness of requiring renamings to work only on the
spec/body combined is that the body might have things in it
that do NOT compile or link on other versions. For example,
the body of one might have the statements:
   TYPE EXACTS is range 1 .. 2**33; -- might exceed

This would cause compilation problems for certain targets which
would declare TYPE EXACTS differently. So you CANNOT just
compile all the different bodies and rename the one you wish,
since some of them will not compile.

Actually, in my experience, most of them will not compile,
because the reason for having multiple backends is specifically
operating system or compile dependencies. That is, things
which were not standardized in the Ada-95 manual, such as
bit lengths, bit orderings, pragma availability, package
availability, access to absolute memory, when things are
guaranteed to be elaborable, and how to read directories,
ports, memory locations, different methods of converting
addresses to integers, etc.

Link errors come from pragma interfaces that do not exist,
calling procedures and functions that are available on one
system only, lack of standardization of what is guaranteed to
elaborate, and changes in names for operating system interfaces.

However, whenever it is applicable, RENAMES can be a very powerful
tool to permit resue of code.

One of the most powerful tools is renaming of default values.
For example, a CHICKEN package gives a set of defaults for
various function formal parameters. The RED_EGG package
fills in one set of defaults and provides these as a VIEW of
the chicken to the user. The BLUE_EGG package fills in a different
set of defaults.

Taken to its limit, it is common practice to use this RENAMING
of DEFAULTS to change an ADT to and ADO. Just implement the ADT
as a PURE package with a limited private type. Then implement
the ADO as a package which declares one object of that limited
private type, initializes it, and RENAMES each of the
procedures and functions in the ADT package to fill in that
object which it just declared. The user then effectively
declares one object per instantiation of the ADO package.
The lack of initialization in the ADT prevents caual misuse of it.

The weakness of using RENAMES to change ADTs to ADOs is that the
instantiated objects cannot be put into an array. This is the
old Packages Are Not First Class Objects argument. (As a reminder,
the Packages Are Not Second Class Objects either argument is
used above: nongeneric packages cannot be passed as parameters
to generic packages). My opinion is that Ada 200X should make
packages second class objects, but not first class objects.

Mike Brenner