[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue: MAPPING-DESTRUCTIVE-INTERACTION (Version 1)
- To: CL-Cleanup@SAIL.Stanford.EDU
- Subject: Issue: MAPPING-DESTRUCTIVE-INTERACTION (Version 1)
- From: Kent M Pitman <KMP@STONY-BROOK.SCRC.Symbolics.COM>
- Date: Mon, 7 Mar 88 16:24 EST
References: MAPCAR, MAPLIST, ... (p128);
DOLIST (p126); MAPHASH (p285);
DO-SYMBOLS, DO-EXTERNAL-SYMBOLS, DO-ALL-SYMBOLS (pp187-188);
All functions using :TEST
Edit history: 07-Mar-88, Version 1 by Pitman
Status: For Internal Discussion
The interaction of mapping functions and DOLIST with destructive
operations on the list being operated on is unclear. For example,
if you destructively modify some tail of a list being mapped down,
does that affect the mapping process?
Document the fact that it is an error for code run by a
"structure traversing" operation to destructively modify the
set of things being traversed while the traversal operation is
(LET* ((L (LIST 'A 'B 'C)) (LL L) (I 0))
(DOLIST (FOO L)
(IF (EQ FOO 'B)
(SETF (CDR LL) NIL)
(LIST I L)) might return (2 (A B)) or (3 (A B)), for example.
The likelihood that the user will want to destructively alter a structure
while it is being traversed is low. The likelihood that such code would
be readable and maintainable is also low. The likelihood that a compiler
could do some interesting optimization if this point were not pinned down
is high enough to be the overriding consideration in this case.
The Symbolics implementation of DOLIST returns (3 (A B)) for the test case.
Cost to Implementors:
None. This simply makes the status quo explicit.
Cost to Users:
Technically none. People who were mistakenly assuming that CLtL guaranteed
things which it does not might be inclined to rewrite their code in a more
Cost of Non-Adoption:
Users would be less informed.
users would be more informed.
Some might say it would be clearer to define this one way or the other, but
advocates of both camps exist and their arguments are fairly symmetric.
In any case, since this is a proposal to preserve the status quo, it has no
major impact on aesthetics.
This idea for this proposal was suggested by the Japanese community.
Pitman drafted the formal proposal and supports