[comp.lang.ada] Elaboration of Library Units

GROVER@TL-20B.TARTAN.COM (Vinod Grover) (10/26/88)

fred@cs.utexas.edu writes 
> 
> [example omitted]
>
> 10.1.2 leads me to believe that package A is elaborated twice;
> my compiler says once; 10.5 is obscure.

LRM 10.1.2 does not specify a general program transformation, where local 
packages can be turned into library level packages. LRM 10.1.2 (8) notes 
that:
    
     "the package STOCK has no visibility of outer identifiers other than
      the predefined identifiers (of package STANDARD). In partcular, STOCK
      does not use any identifier defined in PROCESSOR ...; otherwise
      STOCK could not have been extracted from PROCESSOR."

If this transformation was to be generally valid, then each library unit would
be elaborated as many times as mentioned in with clauses of the transitive
closure of the main program.


As far the elaboration is concerned, several facts are important.

LRM 10.1 (4) says:

     "for the visibility rules, each library unit acts as a declaration that 
      occurs immediately within the package STANDARD."

LRM 10.3 (1) says:

     "The rules defining the order in which units can be compiled are direct
      consequences of the visibilty rules and, in particular, of the fact that
      any library unit that is mentioned by the context clause of a compilation
      unit is visible in the compilation unit."
      

LRM 10.3 (4) says that:

      "The order in which compilation units of a program are compiled must be
       consistent with the partial ordering defined by the above rules".

Deducing from these statements, I believe that the order of "declaration" of
the library units in the package STANDARD must be consistent with the partial
ordering defined by the compilation order, which in turn depends on the
visibility rules required (LRM 10.3 (1)).

We know from LRM 10.3 (4) that each library unit acts as a single
declaration in package STANDARD. Thus this declartion must be elaborated once.
And the sequence of the elaboration is consistent with the implicit declaration
of these library units in STANDARD. This is summed up in LRM 10.5 (2)

     "The elaboration of these library units and of the corresponding library
      unit bodies is performed in an order consistent with this partial  
      ordering defined by the with clauses (see 10.3)."

Thus your compiler is correct in elaborating library units once.

---
Vinod Grover   (Grover@tl-20b.tartan.com)
Tartan Labs.
Pittsburgh, PA 15213
(412)-621-2210
-------