This page is part of the web mail archives of SRFI 1 from before July 7th, 2015. The new archives for SRFI 1 contain all messages, not just those from before July 7th, 2015.
Olin Shivers writes: >Let me present a compromise that I think will preserve maximum ability to use >dotted lists when so desired and still catch errors due to programmers >inadvertently switching atoms and lists. It is essentially what Common Lisp >does. I think your reference to CommonLisp does not support your thesis. In Common Lisp (at least as described in CLTL2) dotted lists are indeed defined in the way you described, but CL list procedures *do not* handle them. Here is a complete list of relevant citations from CLTL2: (page 30:) "When the distinction is important, the term 'true list' will be used to refer to a list terminated by NIL. Most functions advertised to operate on lists expect to be given true lists. Throughout this book, unless otherwise specified, it is an error to pass a dotted list to a function that is specified to require a list as an argument." (page 31:) "Implementation note: Implementors are incouraged to use the equivalent of the predicate ENDP wherever it is necessary to test for the end of a list. Whenever feasible, this test should explicitly signal an error if a list is found to be terminated by a non-NIL atom. However, such an explicit error signal is not required, because some such tests occur in important loops where efficiency is important. In such cases, the predicate ATOM may be used to test for the end of the list, quietly treating any non-NIL list-terminating atom as if it were NIL." (page 412:) "The predicate ENDP is the recommended way to test for the end of a list. It is false of conses, true of NIL, and error for all other arguments. Implementation note: Implementations are encouraged to signal an error, especially in the interpreter, for a non-list argument. The ENDP function is defined so as to allow compiled code to perform simply an atom check or null check if speed is more important than safety." The intent is clear: dotted lists are not acceptable arguments for list functions; the only tradeoff here is between speed and safety. I agree that your compromise solution does rule out most of the non-intuitive cases; but it is indeed a kludge that in my opinion is almost as bad as the problem it is supposed to solve (especially if this approach is meant to be a guideline for list processing). I propose to follow CL in this respect: the recommended way to test for the end of the list would be END? defined to return #t on '(), #f on pairs, and (when speed is more important than safety) report an error for all other arguments. In Scheme 48 END? is called NULL-LIST?. I like both names. Regards, Sergei P.S. I was able to find only 4 CL list functions allowed to accept dotted lists: LAST, APPEND, COPY-LIST, TAILP