aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2012-11-07 00:56:16 -0800
committerGlenn Morris2012-11-07 00:56:16 -0800
commit031b2ea7f5cefc53885d469c3c37ef68103d49aa (patch)
tree848ff6c93f4637a231cce418c226779c1f3078eb
parent9512f8201149fd69b01f8f3f84c64dde995ca12a (diff)
downloademacs-031b2ea7f5cefc53885d469c3c37ef68103d49aa.tar.gz
emacs-031b2ea7f5cefc53885d469c3c37ef68103d49aa.zip
More cl-lib and gv doc updates
* lisp/emacs-lisp/cl.el (define-setf-expander, defsetf) (define-modify-macro): Doc fixes. * doc/misc/cl.texi (Obsolete Setf Customization): Give defsetf gv.el replacements. * etc/NEWS: Related edit.
-rw-r--r--doc/misc/ChangeLog2
-rw-r--r--doc/misc/cl.texi29
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/emacs-lisp/cl.el52
5 files changed, 58 insertions, 32 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 93a2971f8c6..6951f2df79d 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -2,7 +2,7 @@
2 2
3 * cl.texi (Obsolete Setf Customization): 3 * cl.texi (Obsolete Setf Customization):
4 Revert defsetf example to the more correct let rather than prog1. 4 Revert defsetf example to the more correct let rather than prog1.
5 Give define-modify-macro gv.el replacement. 5 Give define-modify-macro and defsetf gv.el replacements.
6 6
72012-11-06 Glenn Morris <rgm@gnu.org> 72012-11-06 Glenn Morris <rgm@gnu.org>
8 8
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 21750b79c93..d3c9ad6aedf 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -5019,14 +5019,16 @@ These translate directly to @code{gv-define-simple-setter}:
5019@end defmac 5019@end defmac
5020 5020
5021@defmac defsetf access-fn arglist (store-var) forms@dots{} 5021@defmac defsetf access-fn arglist (store-var) forms@dots{}
5022This is the second, more complex, form of @code{defsetf}. It is 5022This is the second, more complex, form of @code{defsetf}.
5023rather like @code{defmacro} except for the additional @var{store-var} 5023It can be replaced by @code{gv-define-setter}.
5024argument. The @var{forms} should return a Lisp form that stores 5024
5025the value of @var{store-var} into the generalized variable formed 5025This form of @code{defsetf} is rather like @code{defmacro} except for
5026by a call to @var{access-fn} with arguments described by @var{arglist}. 5026the additional @var{store-var} argument. The @var{forms} should
5027The @var{forms} may begin with a string which documents the @code{setf} 5027return a Lisp form that stores the value of @var{store-var} into the
5028method (analogous to the doc string that appears at the front of a 5028generalized variable formed by a call to @var{access-fn} with
5029function). 5029arguments described by @var{arglist}. The @var{forms} may begin with
5030a string which documents the @code{setf} method (analogous to the doc
5031string that appears at the front of a function).
5030 5032
5031For example, the simple form of @code{defsetf} is shorthand for 5033For example, the simple form of @code{defsetf} is shorthand for
5032 5034
@@ -5041,11 +5043,18 @@ macros like @code{cl-incf} that invoke this
5041setf-method will insert temporary variables as needed to make 5043setf-method will insert temporary variables as needed to make
5042sure the apparent order of evaluation is preserved. 5044sure the apparent order of evaluation is preserved.
5043 5045
5044Another example drawn from the standard package: 5046Another standard example:
5045 5047
5046@example 5048@example
5047(defsetf nth (n x) (store) 5049(defsetf nth (n x) (store)
5048 (list 'setcar (list 'nthcdr n x) store)) 5050 `(setcar (nthcdr ,n ,x) ,store))
5051@end example
5052
5053You could write this using @code{gv-define-setter} as:
5054
5055@example
5056(gv-define-setter nth (store n x)
5057 `(setcar (nthcdr ,n ,x) ,store))
5049@end example 5058@end example
5050@end defmac 5059@end defmac
5051 5060
diff --git a/etc/NEWS b/etc/NEWS
index 33ec17c1960..76126cf6dda 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -339,8 +339,8 @@ rather than making them unbound.
339*** The following methods of extending `setf' are obsolete 339*** The following methods of extending `setf' are obsolete
340(use features from gv.el instead): 340(use features from gv.el instead):
341`define-modify-macro' (use `gv-letplace') 341`define-modify-macro' (use `gv-letplace')
342`defsetf' (use `gv-define-simple-setter', or FIXME) 342`defsetf' (use `gv-define-simple-setter' or `gv-define-setter')
343`define-setf-expander' (use FIXME) 343`define-setf-expander' (use `gv-define-setter' or `gv-define-expander')
344 344
345** Compilation mode 345** Compilation mode
346+++ 346+++
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cfd79fc57ef..ff9684ad175 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12012-11-07 Glenn Morris <rgm@gnu.org> 12012-11-07 Glenn Morris <rgm@gnu.org>
2 2
3 * emacs-lisp/cl.el (define-setf-expander, defsetf)
4 (define-modify-macro): Doc fixes.
5
3 * emacs-lisp/gv.el (gv-letplace): Fix doc typo. 6 * emacs-lisp/gv.el (gv-letplace): Fix doc typo.
4 (gv-define-simple-setter): Update doc of `fix-return'. 7 (gv-define-simple-setter): Update doc of `fix-return'.
5 8
diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el
index 52567f34278..016967bc713 100644
--- a/lisp/emacs-lisp/cl.el
+++ b/lisp/emacs-lisp/cl.el
@@ -547,13 +547,15 @@ deprecated usage of `symbol-function' in place forms)." ; bug#12760
547 547
548(defmacro define-setf-expander (name arglist &rest body) 548(defmacro define-setf-expander (name arglist &rest body)
549 "Define a `setf' method. 549 "Define a `setf' method.
550This method shows how to handle `setf's to places of the form (NAME ARGS...). 550This method shows how to handle `setf's to places of the form
551The argument forms ARGS are bound according to ARGLIST, as if NAME were 551\(NAME ARGS...). The argument forms ARGS are bound according to
552going to be expanded as a macro, then the BODY forms are executed and must 552ARGLIST, as if NAME were going to be expanded as a macro, then
553return a list of five elements: a temporary-variables list, a value-forms 553the BODY forms are executed and must return a list of five elements:
554list, a store-variables list (of length one), a store-form, and an access- 554a temporary-variables list, a value-forms list, a store-variables list
555form. See `gv-define-expander', `gv-define-setter', and `gv-define-expander' 555\(of length one), a store-form, and an access- form.
556for a better and simpler ways to define setf-methods." 556
557See `gv-define-expander', and `gv-define-setter' for better and
558simpler ways to define setf-methods."
557 (declare (debug 559 (declare (debug
558 (&define name cl-lambda-list cl-declarations-or-string def-body))) 560 (&define name cl-lambda-list cl-declarations-or-string def-body)))
559 `(progn 561 `(progn
@@ -566,23 +568,31 @@ for a better and simpler ways to define setf-methods."
566 568
567(defmacro defsetf (name arg1 &rest args) 569(defmacro defsetf (name arg1 &rest args)
568 "Define a `setf' method. 570 "Define a `setf' method.
569This macro is an easy-to-use substitute for `define-setf-expander' that works 571This macro is an easy-to-use substitute for `define-setf-expander'
570well for simple place forms. In the simple `defsetf' form, `setf's of 572that works well for simple place forms.
571the form (setf (NAME ARGS...) VAL) are transformed to function or macro 573
572calls of the form (FUNC ARGS... VAL). Example: 574In the simple `defsetf' form, `setf's of the form (setf (NAME
575ARGS...) VAL) are transformed to function or macro calls of the
576form (FUNC ARGS... VAL). For example:
573 577
574 (defsetf aref aset) 578 (defsetf aref aset)
575 579
580You can replace this form with `gv-define-simple-setter'.
581
576Alternate form: (defsetf NAME ARGLIST (STORE) BODY...). 582Alternate form: (defsetf NAME ARGLIST (STORE) BODY...).
577Here, the above `setf' call is expanded by binding the argument forms ARGS 583
578according to ARGLIST, binding the value form VAL to STORE, then executing 584Here, the above `setf' call is expanded by binding the argument
579BODY, which must return a Lisp form that does the necessary `setf' operation. 585forms ARGS according to ARGLIST, binding the value form VAL to
580Actually, ARGLIST and STORE may be bound to temporary variables which are 586STORE, then executing BODY, which must return a Lisp form that
581introduced automatically to preserve proper execution order of the arguments. 587does the necessary `setf' operation. Actually, ARGLIST and STORE
582Example: 588may be bound to temporary variables which are introduced
589automatically to preserve proper execution order of the arguments.
590For example:
583 591
584 (defsetf nth (n x) (v) `(setcar (nthcdr ,n ,x) ,v)) 592 (defsetf nth (n x) (v) `(setcar (nthcdr ,n ,x) ,v))
585 593
594You can replace this form with `gv-define-setter'.
595
586\(fn NAME [FUNC | ARGLIST (STORE) BODY...])" 596\(fn NAME [FUNC | ARGLIST (STORE) BODY...])"
587 (declare (debug 597 (declare (debug
588 (&define name 598 (&define name
@@ -639,8 +649,12 @@ Example:
639 649
640(defmacro define-modify-macro (name arglist func &optional doc) 650(defmacro define-modify-macro (name arglist func &optional doc)
641 "Define a `setf'-like modify macro. 651 "Define a `setf'-like modify macro.
642If NAME is called, it combines its PLACE argument with the other arguments 652If NAME is called, it combines its PLACE argument with the other
643from ARGLIST using FUNC: (define-modify-macro incf (&optional (n 1)) +)" 653arguments from ARGLIST using FUNC. For example:
654
655 (define-modify-macro incf (&optional (n 1)) +)
656
657You can replace this macro with `gv-letplace'."
644 (declare (debug 658 (declare (debug
645 (&define name cl-lambda-list ;; should exclude &key 659 (&define name cl-lambda-list ;; should exclude &key
646 symbolp &optional stringp))) 660 symbolp &optional stringp)))