www.delorie.com/gnu/docs/guile/guile_121.html   search  
 
Buy GNU books!


Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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.

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

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

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

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

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

Macro: char * SCM_STRING_CHARS (SCM x)
Macro: char * SCM_SYMBOL_CHARS (SCM x)
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!


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003