[comp.lang.ada] Pragma ELABORATE

adh@minster.york.ac.uk (08/30/89)

In article <20600004@inmet> stt@inmet writes:
>The usual fix is to
>determine which package calls which other package at
>elaboration time, and place a pragma Elaborate (see LRM 10.5:3)
>in the calling package referencing the called package.
>Note that if the called package calls other packages, there
>may be a need to include additional pragma Elaborates on
>those lower level packages.  Pragma Elaborate only forces
>elaboration for a single level of dependency.  Hopefully,
>Ada 9X will fix it so that it forces elaboration for
>the closure of dependencies...

I assume that the possible need for additional pragma ELABORATEs is because
there may be further cases of package body being called before it has
elaborated that will be exposed when the first error is fixed.
The problem I have is with the suggestion that pragma ELABORATE should be
changed to force elaboration of all package (actually library unit?)
bodies in the closure of dependencies, as part of 9X.
I don't think this is necessary - the pragma is intended only to indicate
that prior elaboration of a particular body, whose specification will
already have been elaborated, is required.
Indeed, I can contrive examples where the current pragma ELABORATE
will ensure elaboration completes, but the proposed new semantics would
prevent elaboration (i.e. the package whose body carries the pragma ELABORATE
is in the closure of the bodies of units depended upon by the package
named by the pragma ELABORATE). Or am I missing somthing?

Andy Hutcheon (adh@uk.ac.york.minster)

stt@inmet (09/01/89)

We have proposed that pragma Elaborate be changed/augmented
as part of Ada9X.  The proposal suggests that
pragma Elaborate cause the "early" elaboration of all of the
bodies of all packages in the "with" closure of the
specified package.   This is useful because
a package generally doesn't "know" whether any of
its subprograms will be called at elaboration time,
and hence whether it should pragma-elaborate the packages
it depends on.   Furthermore, due to mutual dependency
between packages, it is often hard to insert pragma Elaborates
as needed.  However, the closure approach doesn't need to specify
a specific ordering among the package bodies making up the
closure, and hence isn't affected by mutual dependency issues.

The wording of the proposal is
such that any conflict created by elaborating the closure
of with dependencies is resolved in favor of direct
pragma Elaborates.  Given that, there is no reason
why linkers couldn't implement the proposed semantics
now.  However, the goal of the proposal is to reduce
the rehosting surprises currently possible due
to distinct implementations of elaboration-order
determination, by making the closure implementation
approach a requirement of the language.

Tucker Taft
Intermetrics, Inc.
Cambridge, MA  02138