LISP objects (S-expressions or so called SEXPR's) are divided into two classes: atoms and dotted-pairs. Atoms are further classified as identifiers, integers, big integers, floating point numbers, strings, vectors and function pointers. Dotted-pairs are composite objects constructed by the LISP function cons (where cons[a,b] is denoted by (a . b)). The main universe of discourse for LISP is the closure of the set of all atoms under the operation cons. Of course the trivial operations among numbers are also included.
The syntax of these LISP objects and their corresponding internal data
structure are explained in the following subsections. But before going into
details we would like to make a brief summary of the static structure of
this LISP. There exists 11 different data structures 7 of which corresponds
to the above stated LISP objects. The remaining 4 are for internal use of
which the user has an indirect discernment (like the error objects).
These 11 data structures are all conventionally named to start with a
capital letter X, here they are:
There exist also a numbering of these objects for identification purpose.
As a coding convention the variable `tp' is used all through
the source for a variable that will hold one of these object-identification
number.
These structures are associated to the following capital letter typedef
keywords.
[throughout the next section these keywords will be
used and not the ones with X].
To unify all pointer to these different data structures under a single name a continuous type casting is made: a hypothetical type is assumed, which is now the int type and a pointer type is defined as
typedef int *PSEXP;and all LISP object data structure pointers are explicitly converted by type casting to this hypothetical pointer.
As will be explained in details in the section: Memory Management and GC, the data items are hold in linked memory pages each of which are of a constant size. This size is a multiple of the least-common-factor of the sizes of possible data structures that corresponds to a LISP object. The memory manager, upon demand for such a specific data type, allocates a page of this size, fills it with empty objects of that type, and then put it in a link with the pages of similar kind. So there exist NTYPES-many linked page lists where NTYPES is the count of data types (in this implementa tion 7). The start of these pages are hold in a pointer array.
Each data type has its first byte of common structure. This byte is named as the Xtype field and serves to identify what this object is. It holds the type identification number, described above that has a mnemonic define-name that starts with the letter T (eg. like Tpair).
Furthermore, for convenience, the sizes of each type is stored in an array `sz[NTYPES]' where NTYPES is the total count of above explained data types.
In the following sections, for each data object, first a syntactical explanation is given then the internal data structure is described.