H.7 Extensions to Global and Global'Class Aspects
{
AI12-0079-3}
In addition to the entities specified in
6.1.2,
the Global aspect may be specified for a subtype (including a formal
subtype), formal package, formal subprogram, and formal object of an
anonymous access-to-subprogram type.
Syntax
{
AI12-0079-3}
The following additional syntax is provided for specifying Global and
Global'Class aspects, to more precisely describe the use of generic formal
parameters and dispatching calls within the execution of an operation:
formal_group_designator ::= null |
all
formal_parameter_name ::=
formal_subtype_mark
|
formal_subprogram_name
|
formal_access_to_subprogram_object_name
dispatching_operation_specifier ::=
dispatching_operation_name (
object_name)
Name Resolution Rules
{
AI12-0079-3}
A
formal_parameter_name
shall resolve to statically denote a formal subtype, a formal subprogram,
or a formal object of an anonymous access-to-subprogram type.
{
AI12-0079-3}
The
object_name
that is associated with an
overriding mode shall resolve to statically
denote a formal object, or a formal parameter of the associated entity.
Static Semantics
{
AI12-0079-3}
The presence of the reserved word
overriding in a global mode
indicates that the specification is overriding the mode of a formal parameter
with another mode to reflect the overall effect of an invocation of the
callable entity on the state associated with the corresponding actual
parameter.
{
AI12-0079-3}
The
extended_global_aspect_definition
and
extended_global_aspect_element
can be used to define as part of the Global aspect the
formal parameter
set and the
dispatching operation set
used within an operation. The formal parameter set is identified by a
set of formal parameter names after the reserved word
use. Alternatively,
the reserved word
null may be used to indicate none of the generic
formal parameters, or
all to indicate all of the generic formal
parameters, of any enclosing generic unit (or visible formal package)
might be used within the execution of the operation. If there is no formal
parameter set specified for an operation declared within a generic unit,
it defaults to
use all.
{
AI12-0079-3}
The dispatching operation set is identified by a set of
dispatching_operation_specifiers
after the reserved word
do. It indicates that the Global effects
of dispatching calls that
match one of the
specifiers need not be accounted for by other elements of the Global
aspect, but are instead to be accounted for by the invoker of the operation.
A dispatching call
matches a
dispatching_operation_specifier
if the
name
or
prefix
of the call statically denotes the same operation(s) as that of the
dispatching_operation_specifier,
and at least one of the objects controlling the call is denoted by a
name that statically names the same object as that denoted by the
object_name
of the
dispatching_operation_specifier.
In the absence of any
dispatching_operation_specifiers,
all dispatching calls within the operation are presumed to have the effects
determined by the set of Global'Class aspects that apply to the invoked
dispatching operation.
Ramification: The object “controlling
the call” is not necessarily a controlling parameter of the call
if the call is a function with a controlling result or has parameters
that is such a function. It is one of the objects that provide
the dispatching tag used for the call; that could, for example, be a
parameter of a function used as a parameter to the call, or an object
being assigned to, or a parameter of an enclosing call.
{
AI12-0079-3}
The Global aspect for a subtype identifies the global variables that
might be referenced during default initialization, adjustment as part
of assignment, finalization of an object of the subtype, or conversion
to the subtype, including the evaluation of any assertion expressions
that apply. If not specified for the first subtype of a derived type,
the aspect defaults to that of the ancestor subtype; if not specified
for a nonderived first subtype the aspect defaults to that of the enclosing
library unit. If not specified for a nonfirst subtype
S, the Global
aspect defaults to that of the subtype identified in the
subtype_indication
defining
S.
{
AI12-0079-3}
The Global'Class aspect may be specified for the first subtype of a tagged
type
T, indicating an upper bound on the Global aspect of any
descendant of
T. If not specified, it defaults to Unspecified.
Legality Rules
{
AI12-0079-3}
For a tagged subtype
T, each mode of its Global aspect shall identify
a subset of the variables identified by the corresponding mode, or by
the
in out mode, of the Global'Class aspect of the first subtype
of any ancestor of
T.
{
AI12-0079-3}
If the formal parameter set is anything but
all in the Global
aspect for an operation declared within a generic unit, then the only
generic formal subtypes that may be used, the only formal subprograms
that may be called, and the only formal objects of an anonymous access-to-subprogram
type that may be dereferenced as part of a call or passed as the actual
for an access parameter, are those included in the formal parameter set.
{
AI12-0079-3}
Any dispatching call occurring within the operation that does not match
a
dispatching_operation_specifier
is checked using the Global'Class aspect(s) applicable to the dispatching
operation; if there is a match, there is no checking against other elements
of the Global aspect(s) applicable at the point of call.
Extensions to Ada 2012
{
AI12-0079-3}
These extensions to the Global aspect are new.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe