diff options
| author | Paul Eggert | 2017-04-07 18:54:40 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-04-07 18:54:40 -0700 |
| commit | a2b3fea957440b8358d3632a4a05e41dee964b5d (patch) | |
| tree | a6ef4cf0ba807dfad9ae91b4bfde1935dc999a5f /doc | |
| parent | a614cd416c5dd71702428a008992589395a722fc (diff) | |
| download | emacs-a2b3fea957440b8358d3632a4a05e41dee964b5d.tar.gz emacs-a2b3fea957440b8358d3632a4a05e41dee964b5d.zip | |
Deprecate copy-record in favor of copy-sequence
Since copy-sequence seems to be needed anyway for records, have it
work on records, and remove copy-record as being superfluous.
* doc/lispref/records.texi (Records, Record Functions):
* lisp/emacs-lisp/cl-macs.el (cl-defstruct):
* lisp/emacs-lisp/eieio.el (make-instance, clone):
* test/src/alloc-tests.el (record-3):
Use copy-sequence, not copy-record, to copy records.
* doc/lispref/sequences.texi (Sequence Functions)
(Array Functions): Document that aref and copy-sequence
work on records.
* etc/NEWS: Omit copy-record.
* src/alloc.c (Fcopy_record): Remove.
* src/data.c (Faref): Document that arg can be a record.
* src/fns.c (Fcopy_sequence): Copy records, too.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/records.texi | 37 | ||||
| -rw-r--r-- | doc/lispref/sequences.texi | 23 |
2 files changed, 14 insertions, 46 deletions
diff --git a/doc/lispref/records.texi b/doc/lispref/records.texi index 2533a8a4ca1..7cc36f14068 100644 --- a/doc/lispref/records.texi +++ b/doc/lispref/records.texi | |||
| @@ -13,8 +13,9 @@ underlying representation of @code{cl-defstruct} and @code{defclass} | |||
| 13 | instances. | 13 | instances. |
| 14 | 14 | ||
| 15 | Internally, a record object is much like a vector; its slots can be | 15 | Internally, a record object is much like a vector; its slots can be |
| 16 | accessed using @code{aref}. However, the first slot is used to hold | 16 | accessed using @code{aref} and it can be copied using |
| 17 | its type as returned by @code{type-of}. Also, in the current | 17 | @code{copy-sequence}. However, the first slot is used to hold its |
| 18 | type as returned by @code{type-of}. Also, in the current | ||
| 18 | implementation records can have at most 4096 slots, whereas vectors | 19 | implementation records can have at most 4096 slots, whereas vectors |
| 19 | can be much larger. Like arrays, records use zero-origin indexing: | 20 | can be much larger. Like arrays, records use zero-origin indexing: |
| 20 | the first slot has index 0. | 21 | the first slot has index 0. |
| @@ -74,38 +75,6 @@ This function returns a new record with type @var{type} and | |||
| 74 | @end example | 75 | @end example |
| 75 | @end defun | 76 | @end defun |
| 76 | 77 | ||
| 77 | @defun copy-record record | ||
| 78 | This function returns a shallow copy of @var{record}. The copy is the | ||
| 79 | same type as the original record, and it has the same slots in the | ||
| 80 | same order. | ||
| 81 | |||
| 82 | Storing a new slot into the copy does not affect the original | ||
| 83 | @var{record}, and vice versa. However, the slots of the new record | ||
| 84 | are not copies; they are identical (@code{eq}) to the slots of the | ||
| 85 | original. Therefore, changes made within these slots, as found via | ||
| 86 | the copied record, are also visible in the original record. | ||
| 87 | |||
| 88 | @example | ||
| 89 | @group | ||
| 90 | (setq x (record 'foo 1 2)) | ||
| 91 | @result{} #s(foo 1 2) | ||
| 92 | @end group | ||
| 93 | @group | ||
| 94 | (setq y (copy-record x)) | ||
| 95 | @result{} #s(foo 1 2) | ||
| 96 | @end group | ||
| 97 | |||
| 98 | @group | ||
| 99 | (eq x y) | ||
| 100 | @result{} nil | ||
| 101 | @end group | ||
| 102 | @group | ||
| 103 | (equal x y) | ||
| 104 | @result{} t | ||
| 105 | @end group | ||
| 106 | @end example | ||
| 107 | @end defun | ||
| 108 | |||
| 109 | @node Backward Compatibility | 78 | @node Backward Compatibility |
| 110 | @section Backward Compatibility | 79 | @section Backward Compatibility |
| 111 | 80 | ||
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi index 2c88ee38cb1..93e8fa8a5fa 100644 --- a/doc/lispref/sequences.texi +++ b/doc/lispref/sequences.texi | |||
| @@ -151,20 +151,19 @@ This function generalizes @code{aref} (@pxref{Array Functions}) and | |||
| 151 | @code{nth} (@pxref{Definition of nth}). | 151 | @code{nth} (@pxref{Definition of nth}). |
| 152 | @end defun | 152 | @end defun |
| 153 | 153 | ||
| 154 | @defun copy-sequence sequence | 154 | @defun copy-sequence seqr |
| 155 | @cindex copying sequences | 155 | @cindex copying sequences |
| 156 | This function returns a copy of @var{sequence}. The copy is the same | 156 | This function returns a copy of @var{seqr}, which should be either a |
| 157 | type of object as the original sequence, and it has the same elements | 157 | sequence or a record. The copy is the same type of object as the |
| 158 | in the same order. | 158 | original, and it has the same elements in the same order. |
| 159 | 159 | ||
| 160 | Storing a new element into the copy does not affect the original | 160 | Storing a new element into the copy does not affect the original |
| 161 | @var{sequence}, and vice versa. However, the elements of the new | 161 | @var{seqr}, and vice versa. However, the elements of the copy |
| 162 | sequence are not copies; they are identical (@code{eq}) to the elements | 162 | are not copies; they are identical (@code{eq}) to the elements |
| 163 | of the original. Therefore, changes made within these elements, as | 163 | of the original. Therefore, changes made within these elements, as |
| 164 | found via the copied sequence, are also visible in the original | 164 | found via the copy, are also visible in the original. |
| 165 | sequence. | ||
| 166 | 165 | ||
| 167 | If the sequence is a string with text properties, the property list in | 166 | If the argument is a string with text properties, the property list in |
| 168 | the copy is itself a copy, not shared with the original's property | 167 | the copy is itself a copy, not shared with the original's property |
| 169 | list. However, the actual values of the properties are shared. | 168 | list. However, the actual values of the properties are shared. |
| 170 | @xref{Text Properties}. | 169 | @xref{Text Properties}. |
| @@ -1148,10 +1147,10 @@ vector, a string, a bool-vector or a char-table). | |||
| 1148 | @end example | 1147 | @end example |
| 1149 | @end defun | 1148 | @end defun |
| 1150 | 1149 | ||
| 1151 | @defun aref array index | 1150 | @defun aref arr index |
| 1152 | @cindex array elements | 1151 | @cindex array elements |
| 1153 | This function returns the @var{index}th element of @var{array}. The | 1152 | This function returns the @var{index}th element of the array or record |
| 1154 | first element is at index zero. | 1153 | @var{arr}. The first element is at index zero. |
| 1155 | 1154 | ||
| 1156 | @example | 1155 | @example |
| 1157 | @group | 1156 | @group |