[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue: REDUCE-ARGUMENT-EXTRACTION (version 1)
- To: email@example.com
- Subject: Issue: REDUCE-ARGUMENT-EXTRACTION (version 1)
- From: Dan L. Pierson <pierson@multimax.ARPA>
- Date: Mon, 07 Dec 87 18:37:19 EST
References: REDUCE (pp. 251-252), :KEY arguments (p. 246),
the astronaut structure (pp. 312-313),
see also REMOVE, REMOVE-IF, REMOVE-IF-NOT, DELETE, DELETE-IF,
DELETE-IF-NOT, REMOVE-DUPLICATES, DELETE-DUPLICATES, SUBSTITUTE,
SUBSTITUTE-IF, SUBSTITUTE-IF-NOT, NSUBSTITUTE, NSUBSTITUTE-IF,
NSUBSTITUTE-IF-NOT, FIND, FIND-IF, FIND-IF-NOT, POSITION,
POSITION-IF, POSITION-IF-NOT, COUNT, COUNT-IF, COUNT-IF-NOT,
MISMATCH, SEARCH, SORT, STABLE-SORT, MERGE (pp. 253-261),
SUBST, SUBST-IF, SUBST-IF-NOT, NSUBST, NSUBST-IF, NSUBST-IF-NOT,
SUBLIS, NSUBLIS, MEMBER, MEMBER-IF, MEMBER-IF-NOT (pp. 273-275),
ADJOIN, UNION, NUNION, INTERSECTION, NINTERSECTION,
SET-DIFFERENCE, NSET-DIFFERENCE, SET-EXCLUSIVE-OR,
NSET-EXCLUSIVE-OR, SUBSETP (pp. 276-279),
ASSOC, ASSOC-IF, ASSOC-IF-NOT, RASSOC, RASSOC-IF, RASSOC-IF-NOT
Edit history: Version 1 by Pierson 12/5/87
Issue: For Internal Discussion
REDUCE is the only one of the Common Lisp functions that modify or
search lists and sequences which does not accept a :KEY argument.
This complicates many uses of REDUCE.
Change the definition of REDUCE to take a :KEY keyword.
Using REDUCE to obtain the total of the ages of the possibly empty
sequence of astronauts ASTROS, would currently require:
(REDUCE #'(LAMBDA (&OPTIONAL (X 0) (Y 0)) (+ (PERSON-AGE X) (PERSON-AGE Y)))
If this proposal is adopted, the same result could be obtained with:
(REDUCE #'+ ASTROS :KEY #'PERSON-AGE)
This proposal brings REDUCE into line with the rest of the sequence
and list modifying and searching functions at the cost of slightly
blurring the meaning of :KEY arguments.
Does anyone currently support this as an extension?
Cost to Implementors:
This will require most implementations to make a trivial modification
to REDUCE. Implementations which wish to use this as an opportunity to
further optimize compiled calls to REDUCE will have to undertake more
work (which would be much more difficult today).
Cost to Users:
None, this is an upward compatible extension.
Cost of non-Adoption:
REDUCE will continue to be more difficult to use than other sequence
functions on sequences of complex objects.
REDUCE will become easier to use on sequences of complex objects. It
will be easier for compilers to convert some calls to REDUCE into
Slightly damaged. All :KEY arguments are currently defined to be used
for predicates, this proposal will implicitly broaden :KEY to support
general extraction for any purpose.
Several members of the committee feel that the increased functionality
outweighs the damage to the definition of :KEY. No one has objected
to this change in the recent round of discussions.