Subject: Re: Why cons *pairs*?
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 13 Sep 2006 04:09:15 -0500
Newsgroups: comp.lang.scheme
Message-ID: <3pidnUmJZ8AmV5rYnZ2dnUVZ_t2dnZ2d@speakeasy.net>
Tom Lord <lord@emf.net> wrote:
+---------------
| Why does lisp use pairs rather than, say, triples or quads...?
...
| There's a historic reason, of course.  Lisp was first developed
| as a platform for exploring some AI techniques in which list processing
| was central. The problem became how to represent lists on an IBM 704.
| That machine used 15-bit addresses, each referring to a 36-bit location.
| Special instructions on the machine already treated the 36-bit word
| has being divided into two 15-bit parts (just right to hold an address)
| and two three bit parts (handy for tags and GC bits).
+---------------

And that tradition was continued on the DEC PDP-10, another 36-bit
machine but one with 18-bit addresses, so like the IBM 704 a single
word could store two addresses [but no additional flags]. The PDP-10
had convenient instructions which easily accessed the halves, so:

    car:    hlrz t0,(t0)	; t1 :=  (car t0)
	    popj p, 0

    cdr:    hrrz t0,(t0)
	    popj p, 0

But PDP-10 programmers *loved* to use fall-through to save space, e.g.:

    cadddr: hrrz t0,(t0)
    caddr:  hrrz t0,(t0)
    cadr:   hrrz t0,(t0)
    car:    hlrz t0,(t0)
	    popj p, 0

    cddddr: hrrz t0,(t0)
    cdddr:  hrrz t0,(t0)
    cddr:   hrrz t0,(t0)
    cdr:    hrrz t0,(t0)
	    popj p, 0

    cdaddr: hrrz t0,(t0)
    cdadr:  hrrz t0,(t0)
    cdar:   hlrz t0,(t0)
            hrrz t0,(t0)
	    popj p, 0

And so on...

Anyway, pairs were just so darned *convenient*!


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607