Down to the metal: my other CAR is a CDR

Surprisingly, one of the most frequent complaints of people new to Lisp is that CAR and CDR are weird names. Well, to begin with, FIRST and REST may sound as weird to a non-english speaker, and are longer. In the second place, you can always DEFINE them away to your heart’s content (although, admittedly, you cannot (easily) define them away in other people’s code). Besides, it’s not all clear whether CAR and CDR deal really with lists (and you’d call them first/rest or head/tile) or pairs (first/second?), as this discussion in comp.lang.scheme shows.

Sometimes, CAR and CDR are sighed upon as minor evil and a concession to tradition and old lore. That misses an important point: composability. Try to write the equivalent of CAADR using your new definitions: maybe you’ll change your mind about their inconvenience. All in all, i think that if we hadn’t CAR and CDR, we would have invented them.

 Acis History 704-LlnlThat said, of course those funky names have historical roots. As you probably know, they stand for Contents of the Address/Decrement Register. The first Lisp was implemented in a room-sized IBM 740. You have a snapshot of this beast below (i wanted to show it to you, hence this entry): click on it for a big nice image, or follow this link (posted by Anton van Straaten in comp.lang.scheme) for a lot more. You can also browse a photographed copy of (part of) the IBM 704 Users Manual. For a machine of that size, the manual is amazingly slim. Those were simpler times!. In page 8 you’ll find the origin of our funny names:

Type A instructions use two 15-bit fields (decrement and address) containing numbers in the octal range 00000 to 77777. […] Bits 21-35 are called the address part of an instruction […] Bits 3-17 are called the decrement part of an instruction because they may represent a number substracted from the contents of an index register.

There you’ve got it. As kindly pointed out by Paul in the comments below, more information on the 704 is available here, and you can learn more about the first Lisp in this site.

2 Responses to “Down to the metal: my other CAR is a CDR”

  1. Paul McJones Says:

    You meant IBM 704 rather than IBM 740. Here are more manuals for it (including the complete reference manual — the copy linked to above is incomplete): http://www.bitsavers.org/pdf/ibm/704/ . And here is lots of information about the first Lisp, including the source code: http://www.softwarepreservation.org/projects/LISP/ .


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: