GNU bug report logs - #28627
24.5; doc of `copy-sequence'

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Wed, 27 Sep 2017 20:41:01 UTC

Severity: minor

Found in version 24.5

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 28627 in the body.
You can then email your comments to 28627 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#28627; Package emacs. (Wed, 27 Sep 2017 20:41:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 27 Sep 2017 20:41:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; doc of `copy-sequence'
Date: Wed, 27 Sep 2017 13:40:06 -0700 (PDT)
This (doc string) is not true for an empty sequence:

  "Return a copy of a list, vector, string or char-table."

This ((elisp) `Sequence Functions') is not true for an empty sequence:

     Storing a new element into the copy does not affect the original
     SEQUENCE, and vice versa.  However, the elements of the new
     sequence are not copies; they are identical (eq) to the elements
     of the original.  Therefore, changes made within these elements, as
     found via the copied sequence, are also visible in the original
     sequence.

This has not been true for an empty string since Emacs 23.  It is now
the case, for instance that (eq foo bar) here returns t:

(setq foo ""
      bar (copy-sequence foo))

(Before Emacs 23 it returned nil.)

Similarly, for [].  `copy-sequence' used to give you a new
empty-vector object.  Now it does not.

(However, before those changes the same thing did hold for the empty
list, (): copy-sequence did not return a new empty-list object.)

The doc should make clear that there is only one empty-sequence object,
for each type of sequence.  In particular, `copy-sequence' does not
create a new sequence object if the sequence is empty.


In GNU Emacs 24.5.1 (i686-pc-mingw32)
 of 2015-04-11 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=3D/c/usr --host=3Di686-pc-mingw32'




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 30 Sep 2017 13:05:01 GMT) Full text and rfc822 format available.

Notification sent to Drew Adams <drew.adams <at> oracle.com>:
bug acknowledged by developer. (Sat, 30 Sep 2017 13:05:01 GMT) Full text and rfc822 format available.

Message #10 received at 28627-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 28627-done <at> debbugs.gnu.org
Subject: Re: bug#28627: 24.5; doc of `copy-sequence'
Date: Sat, 30 Sep 2017 16:04:31 +0300
> Date: Wed, 27 Sep 2017 13:40:06 -0700 (PDT)
> From: Drew Adams <drew.adams <at> oracle.com>
> 
> The doc should make clear that there is only one empty-sequence object,
> for each type of sequence.  In particular, `copy-sequence' does not
> create a new sequence object if the sequence is empty.

Thanks.  I didn't feel we should guarantee what we have in the current
implementation, especially as describing all the details might be
tedious (does "vectors" include bool-vector or doesn't it?).  So I
just added a vague statement that copying an empty object may yield
the same object.  I think this is enough for Lisp programmers to
produce a valid and future-proof code.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28627; Package emacs. (Sat, 30 Sep 2017 13:45:01 GMT) Full text and rfc822 format available.

Message #13 received at 28627-done <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Drew Adams <drew.adams <at> oracle.com>
Cc: 28627-done <at> debbugs.gnu.org
Subject: RE: bug#28627: 24.5; doc of `copy-sequence'
Date: Sat, 30 Sep 2017 06:44:47 -0700 (PDT)
> > The doc should make clear that there is only one empty-sequence object,
> > for each type of sequence.  In particular, `copy-sequence' does not
> > create a new sequence object if the sequence is empty.
> 
> Thanks.  I didn't feel we should guarantee what we have in the current
> implementation, especially as describing all the details might be
> tedious (does "vectors" include bool-vector or doesn't it?).  So I
> just added a vague statement that copying an empty object may yield
> the same object.  I think this is enough for Lisp programmers to
> produce a valid and future-proof code.

I agree.  What is important is to amend or remove the general
Statement that it always returns a copy of the sequence.

We could (or not) also stipulate that some sequence types have
only one empty-sequence object, which is what `copy-sequence'
returns for that sequence type.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 29 Oct 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 287 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.