4.1.4 Attributes
Syntax
range_attribute_designator ::= Range[(
static_expression)]
Name Resolution Rules
Legality Rules
Static Semantics
An
attribute_reference
denotes a value, an object, a subprogram, or some other kind of program
entity. Unless explicitly specified otherwise, for an
attribute_reference
that denotes a value or an object, if its type is scalar, then its nominal
subtype is the base subtype of the type; if its type is tagged, its nominal
subtype is the first subtype of the type; otherwise, its nominal subtype
is a subtype of the type without any constraint,
null_exclusion,
or predicate. Similarly, unless explicitly specified otherwise, for an
attribute_reference
that denotes a function, when its result type is scalar, its result subtype
is the base subtype of the type, when its result type is tagged, the
result subtype is the first subtype of the type, and when the result
type is some other type, the result subtype is a subtype of the type
without any constraint,
null_exclusion,
or predicate.
A
range_attribute_reference
X'Range(N) is equivalent to the
range
X'First(N) .. X'Last(N), except that the
prefix
is only evaluated once. Similarly, X'Range is equivalent to X'First ..
X'Last, except that the
prefix
is only evaluated once.
Dynamic Semantics
Implementation Permissions
An implementation may provide implementation-defined
attributes; the
identifier
for an implementation-defined attribute shall differ from those of the
language-defined attributes unless supplied for compatibility with a
previous edition of this International Standard.
4 Attributes are defined throughout this
International Standard, and are summarized in
K.2.
5 In general, the
name
in a
prefix
of an
attribute_reference
(or a
range_attribute_reference)
has to be resolved without using any context. However, in the case of
the Access attribute, the expected type for the
attribute_reference
has to be a single access type, and the resolution of the
name
can use the fact that the type of the object or the profile of the callable
entity denoted by the
prefix
has to match the designated type or be type conformant with the designated
profile of the access type.
Examples
Examples of attributes:
Color'First --
minimum value of the enumeration type Color (see 3.5.1)
Rainbow'Base'First --
same as Color'First (see 3.5.1)
Real'Digits --
precision of the type Real (see 3.5.7)
Board'Last(2) --
upper bound of the second dimension of Board (see 3.6.1)
Board'Range(1) --
index range of the first dimension of Board (see 3.6.1)
Pool(K)'Terminated --
True if task Pool(K) is terminated (see 9.1)
Date'Size --
number of bits for records of type Date (see 3.8)
Message'Address --
address of the record variable Message (see 3.7.1)
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe