3 ms·
Interestingly enough clojure (probably the most widely-used lisp in the real world) uses “first” and “rest”.
by School-Cotton 4y ago
Interestingly enough clojure (probably the most widely-used lisp in the real world) uses “first” and “rest”.
- Ma8ee 4y agoAnd in the theme of the post, I kind of miss those old terms that I remember fondly from learning Scheme a long time ago. Using them felt like incarnating some ancient magic. That said, the terms "first" and "rest" are superior, and one of the things I love about Clojure is that it never makes anything obscure.
- nivertech 4y agoI don't get it. What was wrong with the following abbreviations: "Contents of the Address Register" (CAR), "Contents of the Decrement Register" (CDR)? IMO they're self-describing. It also allow you to use all the premutations of Address and Decrement registers: C[A|D]+R. How do you do this with "first" and "rest"? ;)
- lispm 4y agoLisp uses these names decades before Clojure, see for example the Lisp Machine Manual from 1979 which documents first, second, ..., seventh, rest1, rest2, ...
- School-Cotton 4y agoPerhaps, but the difference is that Clojure primarily uses first/rest, and doesn't have car/cdr at all (AFAIK).
- lispm 4y agoThe difference is that Clojure does not have cons cells with CAR and CDR like in Lisp. The special dot notation (a . b) does not exist in Clojure. Clojure has something like cons, but they don't work like in Lisp. In Lisp the cons cells are the building blocks for ALL list like data structures: lists, circular lists, cons trees, etc. CAR and CDR can have arbitrary contents: (1 . 2) describes a valid cons cell. In Lisp the function CONS accepts two arbitrary objects and returns a cons cell. Where in Clojure the dot notation for cons cells does not exist and where the function cons is a function which accepts an object as first argument and a seq as second argument. It returns a seq. No such function exists in Lisp. Thus CAR and CDR would not make no sense for Clojure, because it does not support CONS cells with CAR and CDR. It uses seqs (etc.) instead. In Lisp there is a style convention that the names FIRST, SECOND, ... and REST should be used in code which uses conses as lists. When conses are used to build trees (which are not lists), the operators CAR, CDR and related are preferred.
- School-Cotton 4y agoIndeed, that makes sense.