From: ········@spawar.navy.mil
Subject: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <1109223982.304936.144300@o13g2000cwo.googlegroups.com>
If I'm not mistaken, 'first' and 'rest' seem like modern user friendly
replacements for 'car' and 'cdr'.

Is it true that car and cdr are only in Common LISP to be able
to run ancient LISP code?

Is there any time I cannot use 'first' and 'rest' instead?/

Chris

From: Jeff
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <CkeTd.48790$tl3.34820@attbi_s02>
········@spawar.navy.mil wrote:

> If I'm not mistaken, 'first' and 'rest' seem like modern user friendly
> replacements for 'car' and 'cdr'.
> 
> Is it true that car and cdr are only in Common LISP to be able
> to run ancient LISP code?

I use first and rest whenever those are the only ones I care about (or
if I'm actually going to use second, third, etc). However, car and cdr
won't be disappearing anytime soon simply because of their combinatory
(?) abilities:

cadr
cddar
...

I can just very quickly look at it and know what is going on.

Jeff M.

-- 
http://www.retrobyte.org
··············@gmail.com
From: David Sletten
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <lEeTd.11940$VD5.5490@twister.socal.rr.com>
········@spawar.navy.mil wrote:

> If I'm not mistaken, 'first' and 'rest' seem like modern user friendly
> replacements for 'car' and 'cdr'.
> 
> Is it true that car and cdr are only in Common LISP to be able
> to run ancient LISP code?
> 
> Is there any time I cannot use 'first' and 'rest' instead?/
> 
> Chris
> 

There shouldn't be anywhere that you _cannot_ use FIRST rather than CAR 
or REST rather than CDR. It's more of a question of where you _should_ 
or _shouldn't_. The issue is that CONS creates arbitrary structures out 
of pairs of pointers. When I am using a CONS chain as a list I tend to 
use FIRST/REST and ENDP. On the other hand, with a tree of CONSes or 
some other convoluted structure I would stick with CAR/CDR and NULL.

As Jeff pointed out, sometimes it's convenient to compose CAR/CDR. But 
often, if you find yourself using some esoteric CDDADR, ... then you 
probably should rethink your data or create a more meaningful accessor.

David Sletten
From: Christopher C. Stacy
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <uwtsymohi.fsf@news.dtpq.com>
········@spawar.navy.mil writes:

> If I'm not mistaken, 'first' and 'rest' seem like modern user friendly
> replacements for 'car' and 'cdr'.
> 
> Is it true that car and cdr are only in Common LISP to be able
> to run ancient LISP code?
> 
> Is there any time I cannot use 'first' and 'rest' instead?/

Sometimes you want to emphasize that you are operating on a single
cons cell, rather than thinking about the fact that this might be 
part of a linked list.  Conceptually, a cons cell has no REST;
it just has a left and a right (CAR and CDR).

You can always just use FIRST and REST, if you like that better.
From: Kent M Pitman
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <upsyqdj4b.fsf@nhplace.com>
······@news.dtpq.com (Christopher C. Stacy) writes:

> ········@spawar.navy.mil writes:
> 
> > If I'm not mistaken, 'first' and 'rest' seem like modern user friendly
> > replacements for 'car' and 'cdr'.
> > 
> > Is it true that car and cdr are only in Common LISP to be able
> > to run ancient LISP code?
> > 
> > Is there any time I cannot use 'first' and 'rest' instead?/
> 
> Sometimes you want to emphasize that you are operating on a single
> cons cell, rather than thinking about the fact that this might be 
> part of a linked list.  Conceptually, a cons cell has no REST;
> it just has a left and a right (CAR and CDR).
> 
> You can always just use FIRST and REST, if you like that better.

I concur with Chris here.

I use CAR/CDR to emphasize the view as a cons qua cons.
I use FIRST/REST to emphasize the view of a cons qua list.

Moroever, though I know people who prefer to eschew CAR/CDR as
antiquated, I find the notion that REST is somehow a more "modern" or
"natural" name for the right side of a cons are kidding themselves
(and managing to kid me).  FIRST and LAST are inherently asymmetric.
FIRST emphasizes access to a single element.  REST emphasizes access
to 0 or more remaining elements (plural).  That's what the English
word connotes.  A list itself is asymmetric in its recursive nature,
which has a tail off to the right, not to the left.  A cons, by contrast,
is entirely symmetric.

If you feel a compulsion not to use CAR/CDR, I recommend LHS and RHS.
At least these compose nicely to LLRHS instead of CAADR (or CDAAR,
depending on which way you define the ordering of the letters, which
is an orthogonal issue)... though I think you'll find a series of L's
and R's hard to pronounce, even if you're an American.  (And still
harder if you're from somewhere in the world that customarily
consolidates L's and R's.)

And, in the end, almost no word doesn't have its etymology in some bit
of utter randomness a long time back.  And what's wrong with a little
history?  What would one use in place of LAMBDA? L?  How about
changing "Lisp" to "List Processing Language", since in the modern
world we spell things out and can have spaces in our filenames.  Who
cares if doing so sets back the world's understanding of what we have
to offer by an extra decade or two in the process.

Personally, I think the history isn't going to hurt anyone.

I think a belief that all conses are lists, that is, that (FIRST X)
means X is best conceptualized as an object of type LIST, by contrast, 
is a much bigger danger.
From: Christopher C. Stacy
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <u8y5dr3q0.fsf@news.dtpq.com>
If we ever changed Lisp, I wish we could call them LHS and RHS.

I have written systems in which the primary data structure 
was referred to as a "CDR" (although pronounced "see-dee-are").

I am also sure that people sometimes like to write programs 
that deal with automobiles.

That said, I don't write the macros LHS and RHS for my code, 
because when people go to read ANSI Common Lisp, they expect 
to see CAR and CDR --  I consider it inappropriate for me to
inflict a new Lisp dialect upon them.
From: Harald Hanche-Olsen
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <pcoekf5596v.fsf@shuttle.math.ntnu.no>
+ ······@news.dtpq.com (Christopher C. Stacy):

| If we ever changed Lisp, I wish we could call them LHS and RHS.
| 
| I have written systems in which the primary data structure 
| was referred to as a "CDR" (although pronounced "see-dee-are").
| 
| I am also sure that people sometimes like to write programs 
| that deal with automobiles.

And I am sure that people sometimes like to write programs that deal
with equations.

Hey, on second thought, I believe that such programs have been written
in the past, in Lisp even (with-teaspoon "Macsyma").

Maybe we should call them FIRST-ITEM and OTHER-ITEM?

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow
From: Christopher C. Stacy
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <uekf5qbas.fsf@news.dtpq.com>
Harald Hanche-Olsen <······@math.ntnu.no> writes:

> + ······@news.dtpq.com (Christopher C. Stacy):
> 
> | If we ever changed Lisp, I wish we could call them LHS and RHS.
> | 
> | I have written systems in which the primary data structure 
> | was referred to as a "CDR" (although pronounced "see-dee-are").
> | 
> | I am also sure that people sometimes like to write programs 
> | that deal with automobiles.
> 
> And I am sure that people sometimes like to write programs that deal
> with equations.
> 
> Hey, on second thought, I believe that such programs have been written
> in the past, in Lisp even (with-teaspoon "Macsyma").

Well, indeed, and I might even be one of the people who 
worked on the program, and wrote some of the parsing code 
in the more recent commercial version.
So maybe I was aware of that.
From: Harald Hanche-Olsen
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <pcoacpt55fj.fsf@shuttle.math.ntnu.no>
+ ······@news.dtpq.com (Christopher C. Stacy):

| Harald Hanche-Olsen <······@math.ntnu.no> writes:
| 
| > Hey, on second thought, I believe that such programs have been written
| > in the past, in Lisp even (with-teaspoon "Macsyma").
| 
| Well, indeed, and I might even be one of the people who 
| worked on the program, and wrote some of the parsing code 
| in the more recent commercial version.
| So maybe I was aware of that.

Ah.  I wasn't aware of that.  My point still stands though, minus the
offensive (?) tone.  (I should at least have dropped the with-teaspoon
bit, though it was not directed at you nor anyone in particular.)

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow
From: Dave Roberts
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <m3vf8gqxs7.fsf@linux.droberts.com>
······@news.dtpq.com (Christopher C. Stacy) writes:

> I have written systems in which the primary data structure 
> was referred to as a "CDR" (although pronounced "see-dee-are").

Telecom billing, perhaps? Call Detail Records?

-- 
Dave Roberts
dave -remove- AT findinglisp DoT com
http://www.findinglisp.com/
From: Christopher C. Stacy
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <usm3kie74.fsf@news.dtpq.com>
Dave Roberts <···········@remove-findinglisp.com> writes:

> ······@news.dtpq.com (Christopher C. Stacy) writes:
> 
> > I have written systems in which the primary data structure 
> > was referred to as a "CDR" (although pronounced "see-dee-are").
> 
> Telecom billing, perhaps? Call Detail Records?

I was trying to be coy...
From: Ray Dillinger
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <OYsTd.8098$m31.102198@typhoon.sonic.net>
Kent M Pitman wrote:

> And, in the end, almost no word doesn't have its etymology in some bit
> of utter randomness a long time back.  And what's wrong with a little
> history?  What would one use in place of LAMBDA? L?  

fn seems to be just fine for Graham's Arc.  I dunno though; I
like lambda.

> How about
> changing "Lisp" to "List Processing Language", since in the modern
> world we spell things out and can have spaces in our filenames.  

Or changing it to 'Lithp' for that sense of self-conscious irony?

> Personally, I think the history isn't going to hurt anyone.

Historicity isn't a bad thing.  Note that even Scheme, which
despite being older than CL, is less influenced by history,
kept car/cdr instead of going to first/rest.

To me the 'final word' on FIRST/REST is that these names have
been available for (and even bound by default in many systems
to) CAR/CDR for 40 years, and have NOT been adopted to any large
extent by programmers. That seems to indicate that programmers
don't find anything particularly amazingly useful in these
bindings.

> I think a belief that all conses are lists, that is, that (FIRST X)
> means X is best conceptualized as an object of type LIST, by contrast, 
> is a much bigger danger.

"Danger" is too strong a word, IMO.  I think the key is that folks
just don't find it terribly useful. There's nothing hard about car/cdr,
and people like them because they are precise ideas related to the
data structure and what is actually happening, rather than the
slipperier concepts that accompany the proposed renaming.

				Bear
From: Trent Buck
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <20050224195824.7044069b@harpo.marx>
Up spake ········@spawar.navy.mil:
> Is it true that car and cdr are only in Common LISP to be able
> to run ancient LISP code?

I think the biggest reason CAR and CDR haven't been replaced is because
they aren't ambiguous (to humans).

CAR and CDR have distinct meanings specific to list handling.  FIRST and
REST are used in other areas, and are also more likely to be used as
variable names.

-- 
-trent, possibly paraphrasing PG or Sussman.
From: Pascal Costanza
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <cvkbb3$5o5$1@snic.vub.ac.be>
········@spawar.navy.mil wrote:
> If I'm not mistaken, 'first' and 'rest' seem like modern user friendly
> replacements for 'car' and 'cdr'.
> 
> Is it true that car and cdr are only in Common LISP to be able
> to run ancient LISP code?

No. The cons cell is a neutral data structure that doesn't have anything 
to do with lists per se. It's "only" a convention to use cons cells for 
building lists, and to use the car of a cons for the contents of a list 
element and the cdr of a cons for the rest of the list.

In (cons 5 6) the car is 5 and the cdr is 6. No lists involved, 
therefore the names "first" and "rest" don't make any sense.

The advantage of the names car and cdr is that they don't mean anything.


Pascal
From: Gorbag
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <HflTd.1$Z42.0@bos-service2.ext.ray.com>
"Pascal Costanza" <··@p-cos.net> wrote in message
·················@snic.vub.ac.be...

> The advantage of the names car and cdr is that they don't mean anything.

Content of the Address Register and Content of the Data Register.
(Ducks and runs)
From: Rob Warnock
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <ZZ-dnSDWUt4DsoLfRVn-3g@speakeasy.net>
Gorbag <······@invalid.acct> wrote:
+---------------
| "Pascal Costanza" <··@p-cos.net> wrote:
| > The advantage of the names car and cdr is that they don't mean anything.
| 
| Content of the Address Register and Content of the Data Register.
+---------------

"Decrement", not "Data": <http://www.catb.org/~esr/jargon/html/C/cdr.html>


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Lars Brinkhoff
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <85psyqxlk9.fsf@junk.nocrew.org>
Pascal Costanza <··@p-cos.net> writes:
> The advantage of the names car and cdr is that they don't mean anything.

My other car is a cdr.
From: Geoffrey Summerhayes
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <ZVoTd.20231$uO.657362@news20.bellglobal.com>
"Lars Brinkhoff" <·········@nocrew.org> wrote in message 
···················@junk.nocrew.org...
> Pascal Costanza <··@p-cos.net> writes:
>> The advantage of the names car and cdr is that they don't mean anything.
>
> My other car is a cdr.

Well, MY other car is a (cadr ack).

--
Geoff
From: Trent Buck
Subject: Re: When CANNOT use 'first'/'rest' in place of 'car'/'cdr'?
Date: 
Message-ID: <20050225045527.7dac20ae@harpo.marx>
Up spake Lars Brinkhoff:
> My other car is a cdr.

Snarf!

-- 
-trent
<foo> I bet they got their degree from the same vending machine.