411 REFERENCE · Wikibooks
Ada Programming/Attributes/'Range
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Attributes 'Range
__TOC__
Description
The meaning of the attribute depends on the meaning of the prefix X.
If X is a scalar subtype, X'Range represents the range of valid values for that subtype, i.e. it is the same as the subtype itself.
If X is a constrained array subtype or an array object, X'Range denotes the index range of X.
In any case, X'Range is equivalent to X'First .. X'Last, but X is only evaluated once.
If X is multidimensional, the attribute needs a static parameter N to identify the N-th index; 'Range (1) is the same as 'Range.
X'Range (N) is equivalent to X'First(N) .. X'Last(N), but X is only evaluated once.
Examples
type T is range 1double_dot ..10; T'Range is equal to T
type A is array (T) of S; these three A'Range is the same as T
type A is array (T'Range) of S; declarations
type A is array (T'First double_dot .. T'Last ) of S; are equivalent
type B is array (T range box <>) of S; B'Range is illegal (B is unconstrained)
subtype SB is B (2 double_dot .. 5); SB'Range is the same as 2 .. 5
type M is array (Boolean, T) of S; M'Range is equivalent to M'Range (1), which is Boolean
M'Range (2) is the same as T
OA: A; OA'Range is the same as T
OB: B (2 double_dot .. 5); OB'Range is equal to 2 .. 5
See also
Wikibook
Ada Programming
Ada Reference Manual
13 3 Operational and Representation Attributes
K Language-Defined Attributes
Range