Path: utzoo!attcan!uunet!ogicse!caesar.cs.montana.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!think!snorkelwacker!bloom-beacon!SCU.BITNET!RDAVIS From: RDAVIS@SCU.BITNET Newsgroups: comp.lang.scheme Subject: (atom? '()) => #t Message-ID: <9003131152.aa20965@mintaka.lcs.mit.edu> Date: 13 Mar 90 14:21:00 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 61 In article <1990Mar7.194937.1421@sun.soe.clarkson.edu>, jk0@sun.soe.clarkson.edu (Jason Coughlin) writes: > Can someone explain the rationale behind treating '() as an atom? It > seems to me that it should be a pair: it's the empty *list* not the > empty *atom*. > Jacob L. Cybulski replies: > When you look at lists from a purely functional point of view then > any list is the result of CONS, whereas () is a primitive object, > thus an atom.... and goes on to define the functional implementation of PAIRS Vincent Mannis writes: > But remember, a list isn't a pair. EXACTLY!!! but then he goes on to say... > It's zero or more pairs connected together via a cdr chain. NO!! I am truly amazed at the apparent confusion between the data structure LIST and its representation via PAIRs. LIST is an inductively defined structure: 1) basis case: the-empty-list is a LIST 2) constructive case: if L is a LIST, then the result of adding X to the front L is a LIST. A very convenient REPRESENTATION of this data structure is defined using the atom NIL for the-empty-list, and the PAIR (or SYMBOLIC EXPRESSION) constructor CONS for the list constructor. A different representation could be chosen, but a list is still a list. Perhaps the (intellectual) confusion could be avoided by using LIST-CONS, FIRST, and REST, instead of CONS, CAR and CDR. In terms of implementation, one is unlikely to define and use a predicate IS-LIST? as it would have to cdr-down the pair it is given to see if it started with NIL. Victor Mannis also points out, correctly: > In fact, a pair is an object to which the car > and cdr procedures may be applied; it has been considered unkosher for > many years to allow (car '()) and (cdr '())." to which Andrew Shalit replies: > Only unkosher in Scheme, not in Common Lisp. "unkosher" is a very subjective term. Those who consider taking car and cdr of nil to be unkosher (myself included), consider it so in Scheme and in Common Lisp (and UCI-, Mac-, Inter-, Rutgers-, Franz-, TLC-, PSL, 1.6,... 1.5). Even when cdr of an atom gets you its property list, it is not a nice thing to do - relying on implementation details. But all of this goes back to age old arguments of the merits of "pure" lisp vs incredibly powerful hacking. I am reminded of Drew McDermott's comment at the 1980 LISP Conference that what he really liked about LISP was that "I can feel the bits between my toes". but I digress... Ruth E. Davis