[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
copy-seq
Date: Tue, 30 May 89 14:51 EDT
From: Barry Margolin <barmar@Think.COM>
"COPY-SEQ creates a copy of sequence. The elements of the result
are EQL to the corresponding elements of sequence." The Notes section
could then mention that the result is EQUALP to the argument.
That is a good rewording. I would not bother with the suggested note,
the cross-reference to EQUALP can just be dropped.
In CLtL, COPY-SEQ doesn't say what the type of its result is, except
that presumably it inherits the remark under SUBSEQ "The result
subsequence is always of the same type as the argument -sequence-."
This latter remark is manifestly false, as it would require
(typep (subseq (list 1 2) 1 1) 'cons) to be true, which is impossible.
Furthermore, it conflicts with the remark on the previous page "Whenever
a sequence function must construct and return a new vector, it always
returns a -simple- vector. Similarly, any strings constructed will be
simple strings." Also the concept "of type" is too ill-defined in
Common Lisp to be appropriate to use in this way (cf. TYPE-OF). Under
REVERSE, REMOVE, and DELETE, CLtL uses the word "kind" which may or may
not mean the same thing as "type".
I would guess that the intention is as follows:
If the first argument to SUBSEQ, COPY-SEQ, or REVERSE is a vector, the
result is a freshly-allocated simple-array of rank 1 that has the same
array-element-type as the argument. If the first argument to SUBSEQ,
COPY-SEQ, or REVERSE is a list, the result is a freshly-allocated list.
If the sequence argument to NREVERSE, 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, SORT, or STABLE-SORT is a vector,
the result is a vector that has the same array-element-type as the
argument. The result may or may not be simple and may or may not be EQ
to the argument. If the sequence argument to NREVERSE, 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,
SORT, or STABLE-SORT is a list, the result is a list.
Alternatively, the intention may have been that the fourth sentence
above:
The result may or may not be
simple and may or may not be EQ to the argument.
should be:
The result may or may not be EQ to the argument. If the result is
a vector that is not EQ to the argument, the result is a
freshly allocated simple-array of rank 1.
Do we need to run a cleanup issue for this? I think it can just be
handled editorially if all the members of the drafting committee agree.
CLtL isn't very specific about what goes on when things are copied in
many cases. COPY-SEQ is described in terms of SUBSEQ, but neither of
them explicitly prohibits the implementation from copying other than
just the backbone of the sequence. However, I definitely think this
restriction was intended, and I doubt any implementation is violating
it. Now that I've discovered this ambiguity, I think the ANS should fix
it.
Agreed.
I haven't even mentioned the fact that the COPY-SEQ description in the
dANS doesn't say that it always returns a newly-allocated sequence (CLtL
says this indirectly, because COPY-SEQ is defined in terms of SUBSEQ,
which says it explicitly, but the dANS only mentions SUBSEQ in the
Notes, which don't count).
Right, it needs to say this. See above.
- References:
- copy-seq
- From: Barry Margolin <barmar@Think.COM>