Comment by sourcepluck

Comment by sourcepluck 9 days ago

7 replies

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

      probably there were no such machine-level instructions, but assembler macros

      https://en.wikipedia.org/wiki/CAR_and_CDR

      • jlokier 9 days ago

        I felt it simplified the description to not mention they were assembler macros, but in retrospect, that was begging for a correction :-)

        The linked page with details was interesting, thanks!

        • kazinator 8 days ago

          The page doesn't say that these were predefined assembler macros provided by IBM. I'm tending toward the interpretation that the Lisp guys themselves (likely Russel) wrote these macros as part of the assembly language implementation of the interpreter. Which means they specified them to the assembler, rather than the other way around.