3 ms·
The LISP model is/was slightly different. Generally there were a lot of slightly different LISP models, but the first few LISPs were organized in cons cells and
by lispm 8y ago
The LISP model is/was slightly different. Generally there were a lot of slightly different LISP models, but the first few LISPs were organized in cons cells and atoms. Actually the latter was 'atomic symbols'. An atomic symbol was kind of an object and some attributes in a property list: typical for symbols and functions. Even numbers were stored as kind of pseudo atomic symbol. See the Lisp 1.5 manual from 1962, section 7.3 - where the memory model is described.
Then LISP models evolved to still use cons cells, but there now are a bunch of primitive objects (which were not introduced by Java, but existed in LISP long before) like certain numbers and characters. LISP then also did not organize everything as atomic symbol. Atoms were not symbols and a bunch of other data types. For example numbers were no longer (pseudo) atomic symbols. There are atoms, but atom then only meant: all data types which are not cons cells. Where originally there were only cons cells and atomic symbols.
LISP tries to avoid to store pointers to primitive numbers/characters and can store them directly. Most objects are tagged and tags for primitive types are stored without added words. Thus a cons cell with two numbers can be two words and each word is some primitive number. The implementation may also avoid to tag cons cells. Instead the pointer to a cons cell will be tagged. Similar is true for vectors. vectors also may not only be vectors of pointers, but can store primitive objects directly and may be optimized for some primitive objects: for example a vector of bits is just a vector header and a one dimensional packed array of bits. The header can't be avoided, but the bits will be stored directly and not as array of pointers to bits. Some objects may be allocated on the stack or in registers - for example primitive numbers may exist multiple times in memory - but other data objects may only exist once - like a string, which is a vector of characters.
So for primitive data types (some numbers, characters, ...) LISP tries to avoid pointers to them, makes them as small as possible, has the tags integrated into the word representation (thus on a 64bit machine typically a fixnum integer will not be able to use all 64 bits, because the tags need to be represented) and integrates the bits in such a way that they can be efficiently set and checked, possibly even by processor instructions - like on a SPARC processor which has 'some' primitive support for that.
Other types of things in memory then are symbols, functions (also machine coded functions) and record-like objects: structures and instances of classes. Those records usually will use a vector to store their slots. Even more data types exist with a low-level representation like hashtables and multi-dimensional arrays. The organization of these objects in memory can be relatively simple (one big pool) or complex (multiple type sorted pools with generations).
- lispm 8y ago> Atoms were not symbols and a bunch of other data types I meant: Atoms were now symbols and a bunch of other data types.