3.2.3 Classification of Operations
An operation operates on a type T
it yields a value of type T
, if it has an operand whose expected
type (see 8.6
) is T
, or if it has an
access parameter or access result type (see 6.1
A predefined operator, or other
language-defined operation such as assignment or a membership test, that
operates on a type, is called a predefined operation
of the type.
The primitive operations
of a type are the
predefined operations of the type, plus any user-defined primitive subprograms.
Term entry: primitive
operations of a type — the operations (such as subprograms)
declared together with the type declarations
Note: Primitive operations are inherited by other types in the same derivation
class of types.
To be honest: Protected subprograms are
not considered to be “primitive subprograms”, even though
they are subprograms, and they are inherited by derived types.
Discussion: We use the term “primitive
subprogram” in most of the rest of the manual. The term “primitive
operation” is used mostly in conceptual discussions.
of a specific type are defined as follows:
The predefined operators of the type (see 4.5
For a derived type, the inherited (see 3.4
For an enumeration type, the enumeration literals
(which are considered parameterless functions — see 3.5.1
For a specific type declared immediately within
any subprograms (in addition to the enumeration literals) that are explicitly
declared immediately within the same package_specification
and that operate on the type;
For a specific type with an explicitly declared primitive "="
operator whose result type is Boolean, the corresponding "/="
operator (see 6.6
For a nonformal type, any subprograms not covered
above [that are explicitly declared immediately within the same declarative
region as the type] and that override (see 8.3
other implicitly declared primitive subprograms of the type.
Discussion: In Ada 83, only subprograms
declared in the visible part were “primitive” (i.e. derivable).
In Ada 95, mostly because of child library units, we include all operations
declared in the private part as well, and all operations that override
It is possible for a subprogram
to be primitive for more than one type, though it is illegal for a subprogram
to be primitive for more than one tagged type. See 3.9
The order of the implicit
declarations when there are both predefined operators and inherited subprograms
is described in 3.4
Types and Classes
Subprograms declared in a generic package specification are never primitive
for a formal type, even if they happen to override an operation of the
formal type. This includes formal subprograms, which are never primitive
operations (that's true even for an abstract formal subprogram).
A primitive subprogram whose
designator is an operator_symbol
is called a primitive operator
Incompatibilities With Ada 83
The attribute S'Base is
no longer defined for nonscalar subtypes. Since this was only permitted
as the prefix of another attribute, and there are no interesting nonscalar
attributes defined for an unconstrained composite or access subtype,
this should not affect any existing programs.
Extensions to Ada 83
The primitive subprograms
(derivable subprograms) include subprograms declared in the private part
of a package specification as well, and those that override implicitly
declared subprograms, even if declared in a body.
Wording Changes from Ada 83
We have dropped the confusing term operation
of a type in favor of the more useful primitive operation of a
type and the phrase operates on a type.
The description of S'Base has been moved to
, “Scalar Types
because it is now defined only for scalar types.
Wording Changes from Ada 95
Clarified that a formal subprogram that happens to override a primitive
operation of a formal type is not a primitive operation (and thus not
a dispatching operation) of the formal type.
Added wording to include access result types in the kinds of operations
that operate on a type T.
Wording Changes from Ada 2005
The implicitly declared "/=" for a primitive
"=" operator is also primitive; this makes it eligible to be
made visible by a use type
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe