Common Lisp supports specialized array element types through the
:element-type argument to
make-array. When an array has a
specialized element type, only elements of that type can be stored in
the array. From this restriction comes two major efficiency
base-chararray can have 4 elements per word, and a
bitarray can have 32. This space-efficient representation is possible because it is not necessary to separately indicate the type of each element.
These are the specialized element types currently supported:
bit (unsigned-byte 2) (unsigned-byte 4) (unsigned-byte 8) (unsigned-byte 16) (unsigned-byte 32) (signed-byte 8) (signed-byte 16) (signed-byte 30) (signed-byte 32) base-character single-float double-float ext:double-double-float (complex single-float) (complex double-float) (complex ext:double-double-float)
simple-vector can hold any type of object,
should still be considered a specialized array type, since arrays with
t are specialized to hold descriptors.
When using non-descriptor representations, it is particularly important to make sure that array accesses are open-coded, since in addition to the generic operation overhead, efficiency is lost when the array element is converted to a descriptor so that it can be passed to (or from) the generic access routine. You can detect inefficient array accesses by enabling efficiency notes, see efficiency-notes. See array-types.