Contents   Index   Search   Previous   Next

3.2.3 Classification of Operations

Static Semantics

   {operates on a type} An operation operates on a type T if 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 (see 6.1) designating T. {predefined operation (of a type)} 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. {primitive operations (of a type)} The primitive operations of a type are the predefined operations of the type, plus any user-defined primitive subprograms.
Glossary entry: {Primitive operations} The primitive operations of a type are the operations (such as subprograms) declared together with the type declaration. They are inherited by other types in the same class of types. For a tagged type, the primitive subprograms are dispatching subprograms, providing run-time polymorphism. A dispatching subprogram may be called with statically tagged operands, in which case the subprogram body invoked is determined at compile time. Alternatively, a dispatching subprogram may be called using a dispatching call, in which case the subprogram body invoked is determined at run time.
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.
   {primitive subprograms (of a type)} The primitive subprograms of a specific type are defined as follows:
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 implicit declarations.
Ramification: 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.
Discussion: The order of the implicit declarations when there are both predefined operators and inherited subprograms is described in 3.4, ``Derived Types and Classes''.
   {primitive operator (of a type)} A primitive subprogram whose designator is an operator_symbol is called a primitive operator.

Incompatibilities With Ada 83

{incompatibilities with Ada 83} The attribute S'Base is no longer defined for non-scalar subtypes. Since this was only permitted as the prefix of another attribute, and there are no interesting non-scalar attributes defined for an unconstrained composite or access subtype, this should not affect any existing programs.

Extensions to Ada 83

{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 3.5, ``Scalar Types'' because it is now defined only for scalar types.

Contents   Index   Search   Previous   Next   Legal