[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r117006: * lisp/emacs-lisp/cl-macs.el (cl-struct-slo
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] trunk r117006: * lisp/emacs-lisp/cl-macs.el (cl-struct-slot-offset): Mark as pure. |
Date: |
Tue, 22 Apr 2014 03:18:24 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117006
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2014-04-21 23:18:15 -0400
message:
* lisp/emacs-lisp/cl-macs.el (cl-struct-slot-offset): Mark as pure.
(cl--set-elt): Don't proclaim as inline.
(cl-struct-slot-value): Remove explicit gv-setter and compiler-macro.
Define as inlinable instead.
(cl-struct-set-slot-value): Remove.
* doc/misc/cl.texi (Structures): Remove cl-struct-set-slot-value.
* lisp/emacs-lisp/cl-lib.el (cl--set-elt): Remove.
* lisp/emacs-lisp/cl-seq.el (cl-replace, cl-substitute, cl-nsubstitute):
Use setf instead.
modified:
doc/misc/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-6331
doc/misc/cl.texi cl.texi-20091113204419-o5vbwnq5f7feedwu-6292
etc/NEWS news-20100311060928-aoit31wvzf25yr1z-1
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/emacs-lisp/cl-lib.el cl.el-20091113204419-o5vbwnq5f7feedwu-614
lisp/emacs-lisp/cl-macs.el clmacs.el-20091113204419-o5vbwnq5f7feedwu-612
lisp/emacs-lisp/cl-seq.el clseq.el-20091113204419-o5vbwnq5f7feedwu-613
=== modified file 'doc/misc/ChangeLog'
--- a/doc/misc/ChangeLog 2014-04-20 02:50:36 +0000
+++ b/doc/misc/ChangeLog 2014-04-22 03:18:15 +0000
@@ -1,3 +1,7 @@
+2014-04-22 Stefan Monnier <address@hidden>
+
+ * cl.texi (Structures): Remove cl-struct-set-slot-value.
+
2014-04-20 Daniel Colascione <address@hidden>
* cl.texi (Declarations): Document changes to `cl-the' and defstruct
functions.
=== modified file 'doc/misc/cl.texi'
--- a/doc/misc/cl.texi 2014-04-20 02:50:36 +0000
+++ b/doc/misc/cl.texi 2014-04-22 03:18:15 +0000
@@ -4278,18 +4278,7 @@
Return the value of slot @code{slot-name} in @code{inst} of
@code{struct-type}. @code{struct} and @code{slot-name} are symbols.
@code{inst} is a structure instance. This routine is also a
address@hidden place. @code{cl-struct-slot-value} uses
address@hidden internally and can signal the same
-errors.
address@hidden defun
-
address@hidden cl-struct-set-slot-value struct-type slot-name inst value
-Set the value of slot @code{slot-name} in @code{inst} of
address@hidden @code{struct} and @code{slot-name} are symbols.
address@hidden is a structure instance. @code{value} is the value to
-which to set the given slot. Return @code{value}.
address@hidden uses @code{cl-struct-set-slot-offset}
-internally and can signal the same errors.
address@hidden place. Can signal the same errors as
@code{cl-struct-slot-offset}.
@end defun
@node Assertions
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2014-04-20 02:50:36 +0000
+++ b/etc/NEWS 2014-04-22 03:18:15 +0000
@@ -99,8 +99,7 @@
** You can specify a function's interactive-only property via `declare'.
However you specify it, the property affects `describe-function' output.
-** You can access the slots of structures using `cl-struct-slot-value'
- and `cl-struct-set-slot-value'.
+** You can access the slots of structures using `cl-struct-slot-value'.
* Changes in Emacs 24.5 on Non-Free Operating Systems
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-04-21 18:00:19 +0000
+++ b/lisp/ChangeLog 2014-04-22 03:18:15 +0000
@@ -1,3 +1,15 @@
+2014-04-22 Stefan Monnier <address@hidden>
+
+ * emacs-lisp/cl-macs.el (cl-struct-slot-offset): Mark as pure.
+ (inline): Don't inline cl--set-elt.
+ (cl-struct-slot-value): Remove explicit gv-setter and compiler-macro.
+ Define as inlinable instead.
+ (cl-struct-set-slot-value): Remove.
+
+ * emacs-lisp/cl-lib.el (cl--set-elt): Remove.
+ * emacs-lisp/cl-seq.el (cl-replace, cl-substitute, cl-nsubstitute):
+ Use setf instead.
+
2014-04-21 Daniel Colascione <address@hidden>
* emacs-lisp/cl-macs.el (cl--const-expr-val): We didn't need the
=== modified file 'lisp/emacs-lisp/cl-lib.el'
--- a/lisp/emacs-lisp/cl-lib.el 2014-04-12 19:30:14 +0000
+++ b/lisp/emacs-lisp/cl-lib.el 2014-04-22 03:18:15 +0000
@@ -152,9 +152,6 @@
`(setq ,place (cl-adjoin ,x ,place ,@keys)))
`(cl-callf2 cl-adjoin ,x ,place ,@keys)))
-(defun cl--set-elt (seq n val)
- (if (listp seq) (setcar (nthcdr n seq) val) (aset seq n val)))
-
(defun cl--set-buffer-substring (start end val)
(save-excursion (delete-region start end)
(goto-char start)
=== modified file 'lisp/emacs-lisp/cl-macs.el'
--- a/lisp/emacs-lisp/cl-macs.el 2014-04-21 18:00:19 +0000
+++ b/lisp/emacs-lisp/cl-macs.el 2014-04-22 03:18:15 +0000
@@ -2621,6 +2621,7 @@
:key #'car :test #'eq)
(error "struct %s has no slot %s" struct-type slot-name)))
(put 'cl-struct-slot-offset 'side-effect-free t)
+(put 'cl-struct-slot-offset 'pure t)
(defvar byte-compile-function-environment)
(defvar byte-compile-macro-environment)
@@ -2907,7 +2908,7 @@
;;; Things that are inline.
(cl-proclaim '(inline cl-acons cl-map cl-concatenate cl-notany
- cl-notevery cl--set-elt cl-revappend cl-nreconc gethash))
+ cl-notevery cl-revappend cl-nreconc gethash))
;;; Things that are side-effect-free.
(mapc (lambda (x) (put x 'side-effect-free t))
@@ -2932,9 +2933,11 @@
(cl-function (lambda (&cl-defs '('*) ,@arglist) ,@body)))))
;;; Additional functions that we can now define because we've defined
-;;; `cl-define-compiler-macro' and `cl-typep'.
+;;; `cl-defsubst' and `cl-typep'.
-(defun cl-struct-slot-value (struct-type slot-name inst)
+(cl-defsubst cl-struct-slot-value (struct-type slot-name inst)
+ ;; The use of `cl-defsubst' here gives us both a compiler-macro
+ ;; and a gv-expander "for free".
"Return the value of slot SLOT-NAME in INST of STRUCT-TYPE.
STRUCT and SLOT-NAME are symbols. INST is a structure instance."
(unless (cl-typep inst struct-type)
@@ -2942,45 +2945,6 @@
(elt inst (cl-struct-slot-offset struct-type slot-name)))
(put 'cl-struct-slot-value 'side-effect-free t)
-(defun cl-struct-set-slot-value (struct-type slot-name inst value)
- "Set the value of slot SLOT-NAME in INST of STRUCT-TYPE.
-STRUCT and SLOT-NAME are symbols. INST is a structure instance.
-VALUE is the value to which to set the given slot. Return
-VALUE."
- (unless (cl-typep inst struct-type)
- (signal 'wrong-type-argument (list struct-type inst)))
- (setf (elt inst (cl-struct-slot-offset struct-type slot-name)) value))
-
-(gv-define-simple-setter cl-struct-slot-value cl-struct-set-slot-value)
-
-(cl-define-compiler-macro cl-struct-slot-value
- (&whole orig struct-type slot-name inst)
- (or (let* ((struct-type (cl--const-expr-val struct-type))
- (slot-name (cl--const-expr-val slot-name)))
- (and struct-type (symbolp struct-type)
- slot-name (symbolp slot-name)
- (assq slot-name (cl-struct-slot-info struct-type))
- (let ((idx (cl-struct-slot-offset struct-type slot-name)))
- (cl-ecase (cl-struct-sequence-type struct-type)
- (vector `(aref (cl-the ,struct-type ,inst) ,idx))
- (list `(nth ,idx (cl-the ,struct-type ,inst)))))))
- orig))
-
-(cl-define-compiler-macro cl-struct-set-slot-value
- (&whole orig struct-type slot-name inst value)
- (or (let* ((struct-type (cl--const-expr-val struct-type))
- (slot-name (cl--const-expr-val slot-name)))
- (and struct-type (symbolp struct-type)
- slot-name (symbolp slot-name)
- (assq slot-name (cl-struct-slot-info struct-type))
- (let ((idx (cl-struct-slot-offset struct-type slot-name)))
- (cl-ecase (cl-struct-sequence-type struct-type)
- (vector `(setf (aref (cl-the ,struct-type ,inst) ,idx)
- ,value))
- (list `(setf (nth ,idx (cl-the ,struct-type ,inst))
- ,value))))))
- orig))
-
(run-hooks 'cl-macs-load-hook)
;; Local variables:
=== modified file 'lisp/emacs-lisp/cl-seq.el'
--- a/lisp/emacs-lisp/cl-seq.el 2014-01-01 07:43:34 +0000
+++ b/lisp/emacs-lisp/cl-seq.el 2014-04-22 03:18:15 +0000
@@ -166,7 +166,7 @@
(cl-n (min (- (or cl-end1 cl-len) cl-start1)
(- (or cl-end2 cl-len) cl-start2))))
(while (>= (setq cl-n (1- cl-n)) 0)
- (cl--set-elt cl-seq1 (+ cl-start1 cl-n)
+ (setf (elt cl-seq1 (+ cl-start1 cl-n))
(elt cl-seq2 (+ cl-start2 cl-n))))))
(if (listp cl-seq1)
(let ((cl-p1 (nthcdr cl-start1 cl-seq1))
@@ -392,7 +392,7 @@
cl-seq
(setq cl-seq (copy-sequence cl-seq))
(or cl-from-end
- (progn (cl--set-elt cl-seq cl-i cl-new)
+ (progn (setf (elt cl-seq cl-i) cl-new)
(setq cl-i (1+ cl-i) cl-count (1- cl-count))))
(apply 'cl-nsubstitute cl-new cl-old cl-seq :count cl-count
:start cl-i cl-keys))))))
@@ -439,7 +439,7 @@
(setq cl-end (1- cl-end))
(if (cl--check-test cl-old (elt cl-seq cl-end))
(progn
- (cl--set-elt cl-seq cl-end cl-new)
+ (setf (elt cl-seq cl-end) cl-new)
(setq cl-count (1- cl-count)))))
(while (and (< cl-start cl-end) (> cl-count 0))
(if (cl--check-test cl-old (aref cl-seq cl-start))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r117006: * lisp/emacs-lisp/cl-macs.el (cl-struct-slot-offset): Mark as pure.,
Stefan Monnier <=