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

Re: assoc question

> Franz Common Lisp and Xerox Common Lisp
> follow the book and permit :key for just assoc (and rassoc), while KCL and
> TI Explorer don't allow :key at all.

On your Explorer, you are probably either using Zetalisp or you are
running with very old software (Release 2).  The Common-Lisp ASSOC
in Release 3.0 of the Explorer follows CLtL and allows for a :KEY arg.

>  In any event, there should certainly
> not be an inconsistency.

I agree, but I think all of the ASSOC functions should accept a :KEY
arg.  Alists are commonly used in Lisp.  Of the following, the ASSOC-IF
version is much easier to read.

;;ALIST is an alist where the CAR's are objects (eg persons)
(assoc-if #'over-the-hill-p alist :key #'age)
(find-if #'over-the-hill-p alist :key #'(lambda (x) (age (car x))))

Since alists are in common use, and it would make the ASSOC functions
consistent with FIND et al, the ASSOC functions should also accept :KEY