Node:Vector Data, Next:, Previous:Pair Data, Up:Non-immediate Datatypes



18.2.5.2 Vectors, Strings, and Symbols

Vectors, strings, and symbols have some properties in common. They all have a length, and they all have an array of elements. In the case of a vector, the elements are SCM values; in the case of a string or symbol, the elements are characters.

All these types store their length (along with some tagging bits) in the CAR of their header cell, and store a pointer to the elements in their CDR. Thus, the SCM_CAR and SCM_CDR macros are (somewhat) meaningful when applied to these datatypes.

int SCM_VECTORP (SCM x) Macro
Return non-zero iff x is a vector.

int SCM_STRINGP (SCM x) Macro
Return non-zero iff x is a string.

int SCM_SYMBOLP (SCM x) Macro
Return non-zero iff x is a symbol.

int SCM_VECTOR_LENGTH (SCM x) Macro
int SCM_STRING_LENGTH (SCM x) Macro
int SCM_SYMBOL_LENGTH (SCM x) Macro
Return the length of the object x. The result is undefined if x is not a vector, string, or symbol, respectively.

SCM * SCM_VECTOR_BASE (SCM x) Macro
Return a pointer to the array of elements of the vector x. The result is undefined if x is not a vector.

char * SCM_STRING_CHARS (SCM x) Macro
char * SCM_SYMBOL_CHARS (SCM x) Macro
Return a pointer to the characters of x. The result is undefined if x is not a symbol or string, respectively.

There are also a few magic values stuffed into memory before a symbol's characters, but you don't want to know about those. What cruft!