Name: Anonymous 2012-02-28 3:00
If you forget for a moment that it's used as syntax in LISP, S-expressions are pretty neat.
Most programming languages use a mix of arrays, structures, vectors, lists, tuples, tables and/or objects to represent and handle data structures. Each of them are similar yet different aggregate structures. With S-expressions, however, there are only pairs or atomic data (doesn't contain a reference to any other value). What are lists? Ordered pairs. What are tuples? Lists. What are vectors? Lists. What are structs? Tuples with compile-time field-labels (implicit accessor procedures).
Now, some of you are complaining ``lists have linear complexity''! Well, ordered pairs only have to behave as linked pairs. They can be allocated in sequential memory locations for constant lookup. CDR-coding makes this automatic and the job of the GC (and CDR-coding is simple if cdrs aren't writable (like arrays or tuple suffixes)).
Good languages only need one tool for creating composite structures: ordered pairs.
Source: Anatomy of Lisp
Most programming languages use a mix of arrays, structures, vectors, lists, tuples, tables and/or objects to represent and handle data structures. Each of them are similar yet different aggregate structures. With S-expressions, however, there are only pairs or atomic data (doesn't contain a reference to any other value). What are lists? Ordered pairs. What are tuples? Lists. What are vectors? Lists. What are structs? Tuples with compile-time field-labels (implicit accessor procedures).
Now, some of you are complaining ``lists have linear complexity''! Well, ordered pairs only have to behave as linked pairs. They can be allocated in sequential memory locations for constant lookup. CDR-coding makes this automatic and the job of the GC (and CDR-coding is simple if cdrs aren't writable (like arrays or tuple suffixes)).
Good languages only need one tool for creating composite structures: ordered pairs.
Source: Anatomy of Lisp