[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue: ASSOC-RASSOC-IF-KEY (Version 2)
- To: CL-Cleanup@SAIL.STANFORD.EDU
- Subject: Issue: ASSOC-RASSOC-IF-KEY (Version 2)
- From: Masinter.pa@Xerox.COM
- Date: 20 Nov 87 12:19 PST
- Cc: vax135!lcuxle!elia@ucbvax.Berkeley.edu, DCP@QUABBIN.SCRC.Symbolics.COM, Masinter.pa@Xerox.COM
- Line-fold: NO
As penance for having dropped this simple issue, I offer you version 2.
I moved some of the discussion around, added a (not very good) example.
This issue sports the new "Cost to implementors" and "Cost to users" section
headings.
A better or more compelling example is welcome.
!
Issue: ASSOC-RASSOC-IF-KEY
References: ASSOC-IF (p280), ASSOC-IF-NOT (p280), RASSOC-IF (p281),
RASSOC-IF-NOT (p281)
Category: ENHANCEMENT
Edit history: 22-Apr-87, Version 1 by Pitman
20-Nov-87, Version 2 by Masinter
Problem Description:
The descriptions of ASSOC-IF, ASSOC-IF-NOT, RASSOC-IF, and RASSOC-IF-NOT
do not mention a :KEY option, although ASSOC and RASSOC have one.
Proposal (ASSOC-RASSOC-IF-KEY:YES):
Allow a :KEY keyword for ASSOC-IF, ASSOC-IF-NOT, RASSOC-IF, and RASSOC-IF-NOT.
If not supplied, it should default to #'IDENTITY as do the :KEY keywords
for other -IF and -IF-NOT functions. The function, as with the :KEY argument
for ASSOC and RASSOC, are applied to the CAR of the pair in the association
list.
Documentation impact:
A better description of the intent might be to say that the car /contains/
the key of the association, and by default the car /is/ the key of the
association.
Example:
(assoc-if #'zerop pathnames :key #'pathname-version)
could be used to search a list indexed by pathnames finding one
with zero version.
Rationale:
This is an inconsistency in the language which is simple to fix.
Current Practice:
Symbolics implements :KEY for the -IF and -IF-NOT assoc functions.
Franz and Xerox follow the book. TI Explorer doe not allow :KEY at all.
Cost to Common Lisp implementors:
A small amount of additional code is necessary to support this in
implementations not already offering it as an extension.
Cost to Common Lisp users:
The change is essentially upward compatible with user code.
Benefits:
This would make the set of -IF and -IF-NOT functions be more regular in
their calling conventions.
Aesthetics:
All the other -IF and -IF-NOT variations of list operations omit the
:TEST and :TEST-NOT keywords, but allow :KEY. For example, consider
the family of MEMBER, MEMBER-IF, and MEMBER-IF-NOT.
Although this introduces additional mechanism, it does so in a way that
probably makes it easier to think about which functions do what, so it
would likely be seen as a simplification.
Discussion:
The omission of :KEY in this situation in CLtL was probably an
oversight.
The cleanup committee supports this change/clarification.