Contents Index Search Previous Next
3.8 Record Types
object is a composite object consisting of named components. The value
of a record object is a composite value consisting of the values of the
| null record
Name Resolution Rules
The expected type for the
, if any, in a
is the type
of the component.
is not permitted if the component is of a limited type.
declares a component
of the record type. Besides components declared
s, the components
of a record type include any components declared by discriminant_specification
of the record type declaration. The identifiers of all components of
a record type shall be distinct.
Within a type_declaration,
a name that denotes a component,
protected subprogram, or entry of the type is allowed only in the following
- A name
that denotes any component, protected subprogram, or entry is allowed
within a representation item that occurs within the declaration of the
- A name
that denotes a noninherited discriminant is allowed within the declaration
of the type, but not within the discriminant_part.
If the discriminant is used to define the constraint of a component,
the bounds of an entry family, or the constraint of the parent subtype
in a derived_type_definition then
its name shall appear alone as a direct_name
(not as part of a larger expression or expanded name). A discriminant
shall not be used to define the constraint of a scalar component.
If the name of the current instance of a type
) is used to define the constraint
of a component, then it shall appear as a direct_name
that is the prefix
of an attribute_reference
whose result is of an access type, and the attribute_reference
shall appear alone.
of a component_declaration
the (nominal) subtype of the component. If the reserved word aliased
appears in the component_definition
then the component is aliased (see 3.10
If the component_list
of a record type is defined by the reserved word null
are no discriminants, then the record type has no components and all
records of the type are null records
. A record_definition
of null record
is equivalent to record null; end record
The elaboration of a record_type_definition
creates the record type and its first subtype, and consists of the elaboration
of the record_definition
elaboration of a record_definition
consists of the elaboration of its component_list
The elaboration of a component_list
consists of the elaboration of the component_item
, if any, in the
order in which they appear.
The elaboration of a
the elaboration of the component_definition
the definition of a composite type, if a component_definition
) includes a name
that denotes a discriminant of the type, or that is an attribute_reference
denotes the current
instance of the type, the expression containing the name
is called a per-object expression
, and the constraint
being defined is called
a per-object constraint
For the elaboration
of a component_definition
of a component_declaration
or the discrete_subtype_definition
of an entry_declaration
for an entry
family (see 9.5.2
), if the constraint
of the subtype_indication
not a per-object constraint, then the subtype_indication
elaborated. On the other hand, if the constraint
is a per-object constraint,
then the elaboration consists of the evaluation of any included expression
that is not part of a per-object expression. Each such expression is
evaluated once unless it is part of a named association in a discriminant
constraint, in which case it is evaluated once for each associated discriminant.
When a per-object constraint
is elaborated (as part of creating an object), each per-object expression
of the constraint is evaluated. For other expressions, the values determined
during the elaboration of the component_definition
are used. Any
checks associated with the enclosing subtype_indication
performed, including the subtype compatibility check (see 3.2.2
and the associated subtype is created.
55 A component_declaration
with several identifiers is equivalent to a sequence of single component_declarations,
as explained in 3.3.1.
56 The default_expression
of a record component is only evaluated upon the creation of a default-initialized
object of the record type (presuming the object has the component, if
it is in a variant_part -- see 3.3.1).
57 The subtype defined
by a component_definition (see 3.6)
has to be a definite subtype.
58 If a record type does
not have a variant_part, then the
same components are present in all values of the type.
59 A record type is limited
if it has the reserved word limited in its definition, or if any
of its components are limited (see 7.5).
predefined operations of a record type include membership tests, qualification,
and explicit conversion. If the record type is nonlimited, they also
include assignment and the predefined equality operators.
61 A component of a record
can be named with a selected_component.
A value of a record can be specified with a record_aggregate,
unless the record type is limited.
record type declarations:
type Date is
Day : Integer range 1 .. 31;
Month : Month_Name;
Year : Integer range 0 .. 4000;
type Complex is
Re : Real := 0.0;
Im : Real := 0.0;
Examples of record
Tomorrow, Yesterday : Date;
A, B, C : Complex;
-- both components of A, B, and C are implicitly initialized to zero
Contents Index Search Previous Next Legal