Next: Elaboration Order, Up: Elaboration Order Handling in GNAT [Contents][Index]
Ada defines the term `execution' as the process by which a construct achieves its run-time effect. This process is also referred to as `elaboration' for declarations and `evaluation' for expressions.
The execution model in Ada allows for certain sections of an Ada program to be executed prior to execution of the program itself, primarily with the intent of initializing data. These sections are referred to as `elaboration code'. Elaboration code is executed as follows:
In addition to the Ada terminology, this appendix defines the following terms:
A construct that is elaborated or executed by elaboration code is referred to as an `elaboration scenario' or simply a `scenario'. GNAT recognizes the following scenarios:
'Access
of entries, operators, and subprograms
A construct elaborated by a scenario is referred to as `elaboration target' or simply `target'. GNAT recognizes the following targets:
'Access
of entries, operators, and subprograms, the target is the
entry, operator, or subprogram being aliased.
Elaboration code may appear in two distinct contexts:
A scenario appears at the library level when it is encapsulated by a package [body] compilation unit, ignoring any other package [body] declarations in between.
with Server; package Client is procedure Proc; package Nested is Val : ... := Server.Func; end Nested; end Client;
In the example above, the call to Server.Func
is an elaboration scenario
because it appears at the library level of package Client
. Note that the
declaration of package Nested
is ignored according to the definition
given above. As a result, the call to Server.Func
will be executed when
the spec of unit Client
is elaborated.
A scenario appears within the statement sequence of a package body when it is
bounded by the region starting from the begin
keyword of the package body
and ending at the end
keyword of the package body.
package body Client is procedure Proc is begin ... end Proc; begin Proc; end Client;
In the example above, the call to Proc
is an elaboration scenario because
it appears within the statement sequence of package body Client
. As a
result, the call to Proc
will be executed when the body of Client
is
elaborated.
Next: Elaboration Order, Up: Elaboration Order Handling in GNAT [Contents][Index]