Posted: Mar 21, 2012 12:06 pm
by VazScep
epepke wrote:Another thing: When I was in my first "LISP is really cool," I argued with someone. She said that LISP was a totally hardware-independent language. I pointed out that CAR and CDR stood for "contents of the address/decrement register," which were a specific implementation. There have been some attempts to use FIRST and REST, but they never caught on.
I'd be one of the people arguing against the use of "first" and "rest."

Common Lisp's basic data-structure isn't a list. It's a mutable pair (a cons cell). It happens that cons cells can be used to implement lists, but they can also be used to implement trees, key-value pairs, cyclic graphs, whatever.

Functions such as "first", "second", "third", "nth" and "rest" are functions which interpret a cons cell as a list. The function "assoc" interprets a cons-cell as an association list. The function "copy-tree" interprets it as a tree. "push" interprets it as an imperative stack. "adjoin" interprets it as a set.

On dirty prototype code, I'd start by implementing everything as cons cell and then writing functions with meaningful names to interpret the data-type more abstractly.