TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Car, Cdr, and Lisp...

8 点作者 mk超过 17 年前

6 条评论

tjr超过 17 年前
The first time I went to Cambridge to visit MIT (and was incidentally first getting into Lisp), I noticed the Massachusetts slogan on the automotive license plates: "Spirit of America".<p>This, of course, made me think of the Beach Boys song "Spirit of America," which includes the lines:<p><pre><code> Once as a jet it played in the stars But now on the ground it's the king of our cars </code></pre> and thus I now have this interesting and seemingly permanent cognitive mapping in my mind between Massachusetts, the Beach Boys, MIT, Lisp, and "car". Lisp without car, to me, would just be awful... but for reasons that likely don't apply to anyone else on the planet. :-)
评论 #116286 未加载
gruseom超过 17 年前
<i>"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."</i><p>So <i>car</i> and <i>cdr</i> have been around for 49 years, while <i>first</i> and <i>rest</i> have been around for 48 1/2. I don't think "historical reasons" explains the survival of car/cdr. How many other things that survive from the first 6 months of Lisp could be called accidental?<p>Edit: this reminds me of the survival of s-expressions. For a long time the plan was to replace them with m-expressions so that Lisp could be a "real" programming language like Fortran. But people kept preferring to write s-expressions. Eventually it became clear that s-expressions were not an unfortunate weakness at all, but one of the best things about Lisp. Obviously the names car/cdr aren't close to this important, but I do think that if there weren't something deeply right about them, they would have been discarded long ago.
greendestiny超过 17 年前
I don't think explanations of the popularity of car and cdr need to be any more complicated than that they were the first and hence using them was consistent - also two 3 letter keywords are better than any alternatives I've ever seen proposed. They could happily be called left and right without any inconsistency with implementation.
inglesp超过 17 年前
I tend to use car and cdr when I'm writing functions with some kind of list recursion, and first and rest when I'm using lists as a data structure - not so much of a difference really, but seems to be a useful way to see quickly what a function's doing.
jcdreads超过 17 年前
Are you sure you didn't mean to point to <a href="http://www.mschaef.com/blog/tech/lisp/car-cdr.html" rel="nofollow">http://www.mschaef.com/blog/tech/lisp/car-cdr.html</a> ?
tel超过 17 年前
Also: cadr. "Firest" doesn't have the same ring.