summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/gv.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2012-11-10 15:13:33 -0800
committerGlenn Morris <rgm@gnu.org>2012-11-10 15:13:33 -0800
commit6baf66d53bbedd85a443e0d69d1f4311a93f0677 (patch)
tree38d7a00d5f7d5aecb86285d334fa15a31e5fbab1 /lisp/emacs-lisp/gv.el
parent05a859c1bd9cd07b2c0fad06a0694e88ea929fcf (diff)
parente4e46889223296e8875548d278340b21db449a4a (diff)
downloademacs-6baf66d53bbedd85a443e0d69d1f4311a93f0677.tar.gz
Merge from emacs-24; up to 2012-11-08T14:54:03Z!monnier@iro.umontreal.ca
Diffstat (limited to 'lisp/emacs-lisp/gv.el')
-rw-r--r--lisp/emacs-lisp/gv.el17
1 files changed, 12 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index 456bace5b1b..58bfae5b503 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -111,7 +111,7 @@ DO must return an Elisp expression."
GETTER will be bound to a copyable expression that returns the value
of PLACE.
SETTER will be bound to a function that takes an expression V and returns
-and new expression that sets PLACE to V.
+a new expression that sets PLACE to V.
BODY should return some Elisp expression E manipulating PLACE via GETTER
and SETTER.
The returned value will then be an Elisp expression that first evaluates
@@ -194,7 +194,7 @@ well for simple place forms.
Assignments of VAL to (NAME ARGS...) are expanded by binding the argument
forms (VAL ARGS...) according to ARGLIST, then executing BODY, which must
return a Lisp form that does the assignment.
-The first arg in ARLIST (the one that receives VAL) receives an expression
+The first arg in ARGLIST (the one that receives VAL) receives an expression
which can do arbitrary things, whereas the other arguments are all guaranteed
to be pure and copyable. Example use:
(gv-define-setter aref (v a i) `(aset ,a ,i ,v))"
@@ -209,13 +209,20 @@ to be pure and copyable. Example use:
This macro is an easy-to-use substitute for `gv-define-expander' that works
well for simple place forms. Assignments of VAL to (NAME ARGS...) are
turned into calls of the form (SETTER ARGS... VAL).
+
If FIX-RETURN is non-nil, then SETTER is not assumed to return VAL and
-instead the assignment is turned into (prog1 VAL (SETTER ARGS... VAL))
+instead the assignment is turned into something equivalent to
+ \(let ((temp VAL))
+ (SETTER ARGS... temp)
+ temp)
so as to preserve the semantics of `setf'."
(declare (debug (sexp (&or symbolp lambda-expr) &optional sexp)))
- (let ((set-call `(cons ',setter (append args (list val)))))
`(gv-define-setter ,name (val &rest args)
- ,(if fix-return `(list 'prog1 val ,set-call) set-call))))
+ ,(if fix-return
+ `(macroexp-let2 nil v val
+ (cons ',setter (append args (list v)))
+ v)
+ `(cons ',setter (append args (list val))))))
;;; Typical operations on generalized variables.