Next: , Previous: , Up: Programming Types   [Contents][Index]


8.4.7 Array Type

An array is composed of an arbitrary number of slots for referring to other Lisp objects, arranged in a contiguous block of memory. Accessing any element of an array takes the same amount of time. In contrast, accessing an element of a list requires time proportional to the position of the element in the list. (Elements at the end of a list take longer to access than elements at the beginning of a list.)

SXEmacs defines three types of array, strings, vectors, and bit vectors. A string is an array of characters, a vector is an array of arbitrary objects, and a bit vector is an array of 1’s and 0’s. All are one-dimensional. (Most other programming languages support multidimensional arrays, but they are not essential; you can get the same effect with an array of arrays.) Each type of array has its own read syntax; see String Type, Vector Type, and Bit Vector Type.

An array may have any length up to the largest integer; but once created, it has a fixed size. The first element of an array has index zero, the second element has index 1, and so on. This is called zero-origin indexing. For example, an array of four elements has indices 0, 1, 2, and 3.

The array type is contained in the sequence type and contains the string type, the vector type, and the bit vector type.