Car and cdr (Re: Python syntax in Lisp and Scheme)

Pascal Costanza costanza at web.de
Mon Oct 13 08:08:17 EDT 2003


Stephen Horne wrote:
> On Mon, 13 Oct 2003 15:28:57 +1300, "Greg Ewing (using
> news.cis.dfn.de)" <g2h5dqi002 at sneakemail.com> wrote:
> 
> 
>>Andrew Dalke wrote:
>>
>>>   It has sometimes been said that Lisp should use first and
>>>   rest instead of car and cdr
>>
>>I used to think something like that would be more logical, too.
>>Until one day it occurred to me that building lists is only
>>one possible, albeit common, use for cons cells. A cons cell
>>is actually a completely general-purpose two-element data
>>structure, and as such its accessors should have names that
>>don't come with any preconceived semantic connotations.
>>
>>From that point of view, "car" and "cdr" are as good
>>as anything!
> 
> 
> "left" and "right" - referring to 'subtrees'?

Sure, why not?

(defun left (tree)
   (car tree))

(defun right (tree)
   (cdr tree))


;-)

Note: Why break anyone else's code just because you prefer a different 
vocabulary?

(Yes, this is different from the Python mindset. What I have learnt from 
this thread is that the languages might seem similar on the technical 
level, but the "social" goals of the languages are vastly different.)


Pascal

-- 
Pascal Costanza               University of Bonn
mailto:costanza at web.de        Institute of Computer Science III
http://www.pascalcostanza.de  Römerstr. 164, D-53117 Bonn (Germany)





More information about the Python-list mailing list