Comment by Chinjut

Comment by Chinjut 9 days ago

10 replies

"Lisp usually prefers expressive names". In addition to the exception of "lambda", there are also "car" and "cdr", which, while not Greek, are hardly transparent.

sourcepluck 9 days ago

If it is any consolation, Steve Russell, who implemented the first Lisp interpreter on the IBM 704 and came up with CAR (Contents of the Address Register) and CDR (Contents of the Decrement Register) wanted to change them to "first" and "rest" after a few months in to teaching and thinking "Hmm, maybe we could have had more direct names here".

See the full email from Steve Russell on the topic on this page https://www.iwriteiam.nl/HaCAR_CDR.html, and here's the relevant quote:

> "After several months and giving a few classes in LISP, we realized that "first" and "rest" were better names, and we (John McCarthy, I and some of the rest of the AI Project) tried to get people to use them instead.

Alas, it was too late! We couldn't make it stick at all. So we have CAR and CDR."

Personally I don't mind them, they're nicely introduced in "A Gentle Introduction to Symbolic Computation" and they stuck easily enough for me.

  • kazinator 9 days ago

    The Fortran-compiled List Programming Language (FLPL) had the functions XCARF and XCDRF. It doesn't look like MacCarthy and Russel invented CAR and CDR; they just stripped X...F from FLPL's notation.

    IPL also used the same list structure; it used the terms SYMB and LINK.

    • jlokier 9 days ago

      The names CAR and CDR weren't invented for Lisp or FLPL. They came from assembly language mnemonics on the IBM 704, where the first Lisp interpreter was implemented.

      The original Lisp CAR and CDR operations used the machine-level instructions with those names on the IBM 704.

      Cons cells were stored in single words of the 36-bit memory and 36/38-bit registers, and the CAR and CDR operations accessed the "address" and "decrement" 15-bit parts of a word, respectively.

      • kazinator 9 days ago

        That's the legend, but they're actually no such instruction mnemonics.

        The Address and Decrement terms and the fields of the 36-bit word they denote do come from the architecture.

        There are instructions like LXA and LXD -- load index from address, load index from decrement.

lispm 9 days ago

"usually" probably means at the time of writing this book. lambda, car and cdr are from the 50s/60s when short names were preferred for various reasons (small memory, input on cards, output on paper, small screens, ...).

kkylin 9 days ago

Yes, but after you get used to it, CADR, CADDR, etc are just a lot easier (and logical!) than SECOND, THIRD, ...