3 ms·
Quoting Xah Lee: > The other fundamental problem in the language is its cons cells as its list construction primitive. > Lisp at core is based on functional p
by Jtsummers 1y ago
Quoting Xah Lee:
> The other fundamental problem in the language is its cons cells as its list construction primitive.
> Lisp at core is based on functional programing on lists.
I found the LISP I manual while thinking about this post and how to respond to some of the comments. An interesting paragraph from it, I think, is important to understand cons in the context of Lisp languages versus whatever Xah Lee is thinking of. From page 14:
> Compositions of car and cdr give the subexpressions of a given expression in a given position. Compositions of cons form expressions of a given structure out of parts. [emphasis in original as underscored text]
Note what is missing from this: Any mention of the word "list". cons, car, and cdr are primitives for the creation and manipulation (or navigation) of S-expressions. Some S-expressions are lists (in the "proper list" sense), but not all. This has been part of the language since the beginning and it makes sense for it to remain part of the language.
In Common Lisp, if you want list specific functions, they do exist. first and rest are synonyms to car and cdr. You can skip cons entirely and use list and append and a few other functions in its place. There are also functions which are generalized to operate on sequences (which includes strings and vectors along with lists).
https://www.mirrorservice.org/sites/www.bitsavers.org/pdf/mit/rle_lisp/LISP_I_Programmers_Manual_Mar60.pdf https://www.mirrorservice.org/sites/www.bitsavers.org/pdf/mi...