From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.bugs Subject: bug#9082: Add hints to documentation of car and cdr for (e)lispnewcomers Date: Thu, 14 Jul 2011 14:20:10 -0700 Message-ID: <1256EB77949E454AA43F66126A20F749@us.oracle.com> References: <8762n4ewfx.fsf@topper.koldfront.dk><87k4bkd61a.fsf@topper.koldfront.dk> <87wrfkboa1.fsf@topper.koldfront.dk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1310678595 9370 80.91.229.12 (14 Jul 2011 21:23:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 14 Jul 2011 21:23:15 +0000 (UTC) Cc: 9082@debbugs.gnu.org To: "'Lars Magne Ingebrigtsen'" , "'Adam "=?UTF-8?Q?Sj=C3=B8gren?="'" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 14 23:23:11 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QhTNG-0000dt-Ix for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Jul 2011 23:23:10 +0200 Original-Received: from localhost ([::1]:48393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhTNF-0004Bd-HH for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Jul 2011 17:23:09 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:60169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhTLF-0003bD-4D for bug-gnu-emacs@gnu.org; Thu, 14 Jul 2011 17:21:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QhTLD-0005O5-1d for bug-gnu-emacs@gnu.org; Thu, 14 Jul 2011 17:21:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhTLC-0005Ny-LV for bug-gnu-emacs@gnu.org; Thu, 14 Jul 2011 17:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QhTLB-000236-Sf; Thu, 14 Jul 2011 17:21:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Drew Adams" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Jul 2011 21:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9082 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 9082-submit@debbugs.gnu.org id=B9082.13106784297829 (code B ref 9082); Thu, 14 Jul 2011 21:21:01 +0000 Original-Received: (at 9082) by debbugs.gnu.org; 14 Jul 2011 21:20:29 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QhTKd-00022E-Rb for submit@debbugs.gnu.org; Thu, 14 Jul 2011 17:20:28 -0400 Original-Received: from rcsinet15.oracle.com ([148.87.113.117]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QhTKb-00021z-Jn for 9082@debbugs.gnu.org; Thu, 14 Jul 2011 17:20:26 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p6ELKHp5010886 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 14 Jul 2011 21:20:19 GMT Original-Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p6ELKG5O015295 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 14 Jul 2011 21:20:17 GMT Original-Received: from abhmt118.oracle.com (abhmt118.oracle.com [141.146.116.70]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p6ELKBA2017515; Thu, 14 Jul 2011 16:20:11 -0500 Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 14 Jul 2011 14:20:10 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: AcxCZ21R+UwbEvMASpuhmDZesja+bQAAmqQQ X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090204.4E1F5D93.0032:SCFMA922111,ss=1,re=-4.000,fgs=0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 14 Jul 2011 17:21:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:49093 Archived-At: > It's really hard to explain these two functions, because they are so > simple and have little intrinsic meaning. Which is why they > were called why they're called, and not `first' and `rest' (which also has > proponents). No, that is not the reason why they were called `car' and `cdr'. http://en.wikipedia.org/wiki/CAR_and_CDR And no, it's not difficult to describe these two functions. It's nearly enough to say: 1. `cons' creates a pair (called a "cons cell" or a "cons") from its two arguments. 2. (car (cons a b)) = a (cdr (cons a b)) = b That's in fact the definition, and it's a pretty good explanation too. I say "nearly" enough because it also helps to explain more about conses and list structure (what's shared, what is not, etc.). Lisp is not a purely functional language, so while #2 above defines these two functions functionally, it does not describe them in terms of behavior. Mainly because it begs the question of `cons', which is not a pure function and which is where list structure comes into the picture. If `cons' were simply a constructor in the functional language (or rewrite or algebra) sense of that word (essentially an undefined function), then #2 above would suffice. > If a user sees > (setq a '(foo . bar)) > (zot (cdr a)) > I don't see how looking up `cdr' and seeing "(rest)" really > unconfuses all that much. Pointing to the manual is the only > thing that will help here, in my opinion. Here, I agree with you, Lars. `rest' does not describe `cdr', especially when `rest' is thought of in terms of purely functional languages. Again, the nub is `cons' and the behavior. It is also true as has been pointed out that the word `rest' is a better fit for true lists than for conses.