all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#28627: 24.5; doc of `copy-sequence'
@ 2017-09-27 20:40 Drew Adams
  2017-09-30 13:04 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2017-09-27 20:40 UTC (permalink / raw)
  To: 28627

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'





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#28627: 24.5; doc of `copy-sequence'
  2017-09-27 20:40 bug#28627: 24.5; doc of `copy-sequence' Drew Adams
@ 2017-09-30 13:04 ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2017-09-30 13:04 UTC (permalink / raw)
  To: Drew Adams; +Cc: 28627-done

> Date: Wed, 27 Sep 2017 13:40:06 -0700 (PDT)
> From: Drew Adams <drew.adams@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.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#28627: 24.5; doc of `copy-sequence'
       [not found] ` <<83h8vk49sw.fsf@gnu.org>
@ 2017-09-30 13:44   ` Drew Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2017-09-30 13:44 UTC (permalink / raw)
  To: Eli Zaretskii, Drew Adams; +Cc: 28627-done

> > 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.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-30 13:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-27 20:40 bug#28627: 24.5; doc of `copy-sequence' Drew Adams
2017-09-30 13:04 ` Eli Zaretskii
     [not found] <<f340c619-3b86-4687-af74-21a441c127c0@default>
     [not found] ` <<83h8vk49sw.fsf@gnu.org>
2017-09-30 13:44   ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.