Contents Index Search Previous Next
3.2.3 Classification of Operations
Static Semantics
1
{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.
1.a
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.
1.b
To be honest: Protected
subprograms are not considered to be ``primitive subprograms,'' even
though they are subprograms, and they are inherited by derived types.
1.c
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.
2
{primitive
subprograms (of a type)} The
primitive
subprograms of a specific type are defined as follows:
3
- The predefined operators of the type
(see 4.5);
4
- For a derived type, the inherited
(see 3.4) user-defined subprograms;
5
- For an enumeration type, the enumeration
literals (which are considered parameterless functions -- see 3.5.1);
6
- For a specific type declared immediately
within a package_specification,
any subprograms (in addition to the enumeration literals) that are explicitly
declared immediately within the same package_specification
and that operate on the type;
7
- {override (a primitive
subprogram)} 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.
7.a
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.
7.b
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.
7.c
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''.
8
{primitive operator (of a type)}
A primitive subprogram whose designator is an
operator_symbol
is called a
primitive operator.
Incompatibilities With Ada 83
8.a
{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
8.b
{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
8.c
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.
8.d
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