[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Add LIST?.

Jim Miller:
    For virtually every data type mentioned in a procedure header line in
    R4RS there is either an existing predicate in the language (string?
    for string, vector? for vector, rational? for q_{n}, etc.) or a
    trivial piece of code (like (lambda (k) (and (integer? k) (exact? k)
    (positive? k))) for k_{n}).  Not so for (proper) lists referred to as
    "list" in the header line.  It was our intention to have P1178 make
    this connection explicit, whether or not R4RS chooses to do so, and
    the missing predicate for proper lists causes a problem.

    We had not planned to ask RNRS to change to add such a test.  But
    someone else has, so I'd like to support the addition of the predicate
    LIST? that tests for proper lists.  I don't mind if you call it
    PROPER-LIST?, but I prefer the other name, especially since the
    language of the report is very clear about the definition of a list,
    and it excludes both cdr-circularity and dotted tails.  Another
    predicate might be of interest to RnRS (NOT-TAIL-CIRCULAR?  or some
    such) but you won't hear me agitating to have that added to the IEEE

Several have spoken in favor of this procedure, and none have opposed it.
There has been some debate about the name; a minority prefers PROPER-LIST?
to LIST?.  The minority consists of two people, since I have changed my
mind and now prefer LIST?.  To summarize that debate, LIST? is more
consistent with the terminology used in Scheme but PROPER-LIST? is more
consistent with the terminology used in Common Lisp.

I will add LIST? to the R3.99RS and R4RS as an essential procedure provided
the authors will join me in a rousing chorus of "YES, YES!".  Proposed

    (LIST? obj)                                      essential procedure

    List? returns #t if obj is a list of finite length, and otherwise
    returns #f.

        (list '(a b c))                      ==>  #t
        (list '())                           ==>  #t
        (list '(a . b))                      ==>  #f
        (let ((x (list 'a)))
          (set-cdr! x x)
          (list? x))                         ==>  #f

Peace, Will