An array can be a general array, meaning each element may be any object, or it may be a specialized array, meaning that each element must be of a restricted type.
The phrasing “an array specialized to type «type»”
is sometimes used to emphasize the element type of an array.
This phrasing is tolerated even when the «type» is t
,
even though an array specialized to type t
is a general array, not a specialized array.
The next figure lists some defined names that are applicable to array creation, access, and information operations.
|
Figure 15.1: General Purpose Array-Related Defined Names
The upgraded array element type of a type T1
is a type T2 that is a supertype of T1
and that is used instead of T1 whenever T1
is used as an array element type for object creation or type discrimination.
During creation of an array, the element type that was requested is called the expressed array element type. The upgraded array element type of the expressed array element type becomes the actual array element type of the array that is created.
Type upgrading implies a movement upwards in the type hierarchy lattice. A type is always a subtype of its upgraded array element type. Also, if a type Tx is a subtype of another type Ty, then the upgraded array element type of Tx
must be a subtype of the upgraded array element type of Ty. Two disjoint types can be upgraded to the same type.
The upgraded array element type T2 of a type T1
is a function only of T1 itself;
that is, it is independent of any other property of the array
for which T2 will be used,
such as rank, adjustability, fill pointers, or displacement.
The function upgraded-array-element-type
can be used by conforming programs to predict how the implementation
will upgrade a given type.
Vectors whose elements are restricted to type
character
or a subtype of character
are called
strings.
Strings are of type string
.
The next figure lists some defined names related to strings.
Strings are specialized arrays and might logically have been included in this chapter. However, for purposes of readability most information about strings does not appear in this chapter; see instead Chapter 16 (Strings).
|
Figure 15.2: Operators that Manipulate Strings
Vectors whose elements are restricted to type
bit
are called
bit vectors.
Bit vectors are of type bit-vector
.
The next figure lists some defined names for operations on bit arrays.