H.7 Extensions to Global and Global'Class Aspects
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.
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
Name Resolution Rules
shall resolve to statically denote a formal subtype, a formal subprogram,
or a formal object of an anonymous access-to-subprogram type.
that is associated with an overriding mode shall resolve to statically
denote a formal object, or a formal parameter of the associated entity.
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.
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.
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
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
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.
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
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.
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.
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.
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
These extensions to the Global
aspect are new.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe