Path: utzoo!attcan!uunet!mcsun!ukc!edcastle!aiai!jeff From: jeff@aiai.ed.ac.uk (Jeff Dalton) Newsgroups: comp.lang.lisp Subject: Re: Correct LisP (was Re: in defense of C) Message-ID: <2073@skye.ed.ac.uk> Date: 19 Mar 90 17:51:21 GMT References: <1942@skye.ed.ac.uk> <14236@cbnewsc.ATT.COM> <12572711825024@AIDA.CSD.UU.SE> <1990Mar12.104518.1412@hellgate.utah.edu> <2452@quiche.cs.mcgill.ca> <2035@skye.ed.ac.uk> <12574182161036@AIDA.CSD.UU.SE> Reply-To: jeff@aiai.UUCP (Jeff Dalton) Organization: AIAI, University of Edinburgh, Scotland Lines: 45 In article <12574182161036@AIDA.CSD.UU.SE> D89.JOHNNY-BILLQUIST@AIDA.CSD.UU.SE (Johnny Billquist) writes: >In artricle <2035@skye.ed.ac.uk> jeff@aiai.ed.ac.uk (Jeff Dalton) writes: > >>One certainly shouldn't use CAR and CDR for some abstractions, but >>why not use them on lists? > >Because lists are an abstraction. I agree for "some abstractions", so you need an argument about "all abstractions" or else one about why lists are among the ones that must be treated abstractly in this way. I'd already taken the simple "lists are an abstraction" into account, and as far as I could tell the benefits of using FIRST and REST in Lisp, and restricting CAR and CDR to pairs, are chiefly (but not entirely) ideological rather than practical. Note that "don't use CAR and CDR on lists" is not the same as saying "the data structure LIST should not be confused with its representation as PAIRS". I agree with the latter but not the former. I have no objection to someone using FIRST and REST if they want to, but I regard it as chiefly a matter of style. In an earlier message you wrote: The correct argument to CAR and CDR is *not* lists, but s-expr (punctuated pairs to be specific). The fact that most (if not all) LisPs implement lists by punctuated pairs is a feature you should not rely upon. That is why the functions FIRST and REST exists. Sure, they do just CAR and CDR, but what if you stumles upon a LisP which implement lists in another way? Well, what if you stumble on a Lisp that has CAR and CDR for *lists* and PAIR-LEFT and PAIR-RIGHT (or something) for pairs? In any case, most of the time programmers are not writing Lisp but some particular kind of Lisp such as Common Lisp or Scheme. That something that still counts as Lisp might implement lists in some other way is not much of a problem in practice. However, using CAR and CDR for other data structures built on top of lists or pairs is another matter. Nothing I've said should be taken as an argument against treating those structures abstractly. Nor do I think it would necessarily be a bad idea to define a Lisp in which lists and pairs *were* distinct. -- Jeff