From: Leonardo Kenji Shikida
Subject: What does mean...
Date: 
Message-ID: <61iers$4ku$1@news.dcc.ufmg.br>
What does mean "car" and "cdr" ? I know what they do, but i was
curious to know what these terms really mean...

(what is the "c", the "d", the "a"  and the "r" ?)

Thanks in advance

--

Abraco
______________________________________________________________________________
Leonardo Kenji Shikida ............... Graduando em Ciencia da Computacao/UFMG
Diretor de Recursos Humanos ........................ UIJR/UFMG Informatica Jr.
http://www.dcc.ufmg.br/~kenji .............................. ·····@dcc.ufmg.br
------------------------------------------------------------------------------

From: William Paul Vrotney
Subject: Re: What does mean...
Date: 
Message-ID: <vrotneyEI2Ktn.Fzu@netcom.com>
In article <············@news.dcc.ufmg.br> ·····@dcc.ufmg.br (Leonardo Kenji
Shikida) writes:

> 
> What does mean "car" and "cdr" ? I know what they do, but i was
> curious to know what these terms really mean...
> 
> (what is the "c", the "d", the "a"  and the "r" ?)
> 

They are borrowed from an old IBM 704 computer that had partial word
instructions that could reference the *address* and *decrement* part of a
machine location.  Consequently they stand for

        CAR = Contents of Address Register part
        CDR = Contents of Decrement Register part

The original Lisp was implemented on the IBM 704 and these were as good as
any choice to remind the programmer of the contents of the left and right
parts of a Lisp word being the CONS (CONStruct).  You might think they
should have chosen LEFT and RIGHT instead but then what would they have used
today for functions like CAAR, CADAR, CDADR etc. :-)



-- 

William P. Vrotney - ·······@netcom.com
From: Kent M Pitman
Subject: Re: What does mean...
Date: 
Message-ID: <sfwiuuzhdkc.fsf@world.std.com>
·······@netcom.com (William Paul Vrotney) writes:

> You might think they should have chosen LEFT and RIGHT instead but
> then what would they have used today for functions like CAAR, CADAR,
> CDADR etc. :-)

Somewhere along the way, someone did observe that LHS and RHS (Left and
Right Hand Side) would work.  LLRLHS, for example.  But it never caught on.
It's not really remarkably pronounceable.  It's incompatible.  And it's
not as fun trivia-wise.
From: Barry Margolin
Subject: Re: What does mean...
Date: 
Message-ID: <621lpu$in4@pasilla.bbnplanet.com>
In article <···············@world.std.com>,
Kent M Pitman <······@world.std.com> wrote:
>Somewhere along the way, someone did observe that LHS and RHS (Left and
>Right Hand Side) would work.  LLRLHS, for example.  But it never caught on.
>It's not really remarkably pronounceable.  It's incompatible.  And it's
>not as fun trivia-wise.

The Lisp community managed to figure out how to pronounce "LDB" and "DPB",
so I think we could manage this.  I think RHS could be pronounced "rush";
thus, instead of "cdr'ing down a list" we would "rush down a list".  Not a
bad image.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>
Please don't send technical questions directly to me, post them to newsgroups.
From: Josh Yelon
Subject: Re: What does mean...
Date: 
Message-ID: <3449BE06.4582D816@uiuc.edu>
Barry Margolin wrote:
> 
> In article <···············@world.std.com>,
> Kent M Pitman <······@world.std.com> wrote:
> >Somewhere along the way, someone did observe that LHS and RHS (Left and
> >Right Hand Side) would work.  LLRLHS, for example.  But it never caught on.
> >It's not really remarkably pronounceable.  It's incompatible.  And it's
> >not as fun trivia-wise.
> 
> The Lisp community managed to figure out how to pronounce "LDB" and "DPB",
> so I think we could manage this.  I think RHS could be pronounced "rush";
> thus, instead of "cdr'ing down a list" we would "rush down a list".  Not a
> bad image.

Wouldn't that imply that we'd have to "lush" down the left side of a
tree?  Sort of a drunken image. :)
From: Wayne Throop
Subject: Re: What does mean...
Date: 
Message-ID: <876890003@sheol.org>
:: What does mean "car" and "cdr" ? I know what they do, but i was
:: curious to know what these terms really mean... 
:: 
:: (what is the "c", the "d", the "a" and the "r" ?)

: ·······@netcom.com (William Paul Vrotney)
:
:         CAR = Contents of Address Register part
:         CDR = Contents of Decrement Register part
: 
: The original Lisp was implemented on the IBM 704 and these were as
: good as any choice to remind the programmer of the contents of the
: left and right parts of a Lisp word being the CONS (CONStruct).  You
: might think they should have chosen LEFT and RIGHT instead but then
: what would they have used today for functions like CAAR, CADAR, CDADR
: etc.  :-)

Well, they could have named them FIRST and REST,
and the local navigation ones FFIRST, FRFIRST, RFREST, and so on.
--
Wayne Throop   ·······@sheol.org   http://sheol.org/throopw
From: Barry Margolin
Subject: Re: What does mean...
Date: 
Message-ID: <621mpp$4gf@pasilla.bbnplanet.com>
In article <·········@sheol.org>, Wayne Throop <·······@sheol.org> wrote:
>Well, they could have named them FIRST and REST,

Those names don't make sense when the cons is being used as part of a
non-list data structure.  E.g. when you're making a tree, the CAR is the
left subtree and the CDR is the right subtree, and neither one is "first"
or "rest".

One of the arguments (or rationalizations, perhaps) for retaining the
archaic names is precisely their meaninglessness.  By avoiding
preconceptions, the generality of the simple cons data structure is
emphasized.

On the other hand, these days programmers are encouraged to use DEFSTRUCT
or CLOS as the building blocks for general data structures.  But it's nice
to be reminded of our heritage.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>
Please don't send technical questions directly to me, post them to newsgroups.
From: Kent M Pitman
Subject: Re: What does mean...
Date: 
Message-ID: <sfw7mbf2rld.fsf@world.std.com>
Barry Margolin <······@bbnplanet.com> writes:

> On the other hand, these days programmers are encouraged to use DEFSTRUCT
> or CLOS as the building blocks for general data structures.  But it's nice
> to be reminded of our heritage.

Ah, but DEFSTRUCT and CLOS allocation of a pair of words is often
50% less storage-efficient than a CONS.

Oh, for the days of HUNKs... (just reminding you of our heritage)

In case anyone is curious, a Lisp dialect called Maclisp (for the
PDP10, no relation to the Macxxx series of products for the Macintosh
which didn't come along until years later) had a datatype called a
HUNK which was really a set of datatypes HUNK2, HUNK4, ...,
HUNK512. which were generalized conses.  A HUNK2 was for all practical
purposes like a CONS so that (CAR '(A . Z .)) and (CDR '(A . Z .))
were A and Z even.  And there was (hunk 'a 'z), etc. for making
non-constant hunks.  But (CAR '(A . B . Z .)) => A and 
(CDR '(A . B . Z .)) => Z and the (CXR n '(A . B . Z .)) for n=0,1,2 
were Z,A,B, (so that CAR was always the first and CDR was always the 
last(0) and there might be things in "the middle").  Note that CXR
was not like NTH in spite of the listy notation--it's more like AREF
and the whole hunk was the analog of a cons.  In the case of
'(A . B . Z .) you got a HUNK4 but its HUNKSIZE was 3; it had a magic
"unused" filler in the extra unused cell.  '(A . B . C . Z .) was
also a HUNK4 (same amount of storage) but had HUNKSIZE 4.
'(A . B . C . D . Z .) was a HUNK8 with HUNKSIZE 5.  That meant it 
took up a nice power of 2 memory size and would get gc'd into a
socially responsible amount of space.  One could make lists with 
backpointers where CAR and CDR worked by using a HUNK of size 3 
with a "middle" of each cons that pointed back. e.g., [if I don't
blow this--I no longer have a way to test it :-]...
 '#1=(A . NIL . #2=(B . #1# . (C . #2# . NIL .)))
So you could do
 (member 'b '#1=(A . NIL . #2=(B . #1# . (C . #2# . NIL .))))
 => #1=(B . (A . NIL . #1#) . (C . #1# . NIL .))
and you could write 
 (defun uncdr (x) (cxr 2 x))
but you had to remember only to call it on hunks for which you'd
filled the slots in a way that made that meaningful (since myriad
hunks were running around behind your back with other silly 
purposes thought up by other package-writers).  And then again, 
this whole backpointer thing took 4 cells even though each "hunk" 
is a hunk3 so I suppose I might as well be using DEFSTRUCT.  But
it was just so cool to have all that pre-defined compatibility
with CONS that one could get lost in it and not care. And one could 
always find something else to do with the extra cell... a property
list on the cons, for example.

HUNKs were exploited in the latter days of Maclisp (when there were not
yet class systems) and became implementation fodder for compatibility
packages with future functionality.  I think this kept them from ever
achieving any first-class significance because no one had any serious
code that used hunks as a user-visible structure for fear it would
break when the compatibility packages were turned on.

But there are days when I kind of miss them.  They were, like CONS,
a kind of nice low-tech, anonymous, data structure with lots of neat
stuff prepackaged for use.  I think that's what gives CONS its appeal.
It's kind of an "anonymous" datatype where you can experiment before
giving an object its own identifiable type.

I note also as an aside that some lisps for the CDC series of machines
(72 bits) divided the word into three 24 bit pointers and had a
CAR/CDR/CSR.  This was less general than the HUNK.  But it led to some
similar hacks.  But then, the bits were there going mostly to waste at
the time.  Who needed more than 24 bits of pointer...? ;-)
 --Kent

- - -
My other car is a (function (lambda (hunk) (cxr 1 hunk))).
From: Emergent Technologies
Subject: Re: What does mean...
Date: 
Message-ID: <u67qy62wh.fsf@cape.com>
MIT Scheme still has some hunks under the hood.