aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-11-08 08:34:06 -0500
committerStefan Monnier2012-11-08 08:34:06 -0500
commitd14bb752ea51331ce2fb459c6ffacd8b11f80bb0 (patch)
tree268bc5ea61b92967abb8befac626ef8b87c0d230
parentc66f21eaf103f9ace7400f3d8a06fc34539efca9 (diff)
downloademacs-d14bb752ea51331ce2fb459c6ffacd8b11f80bb0.tar.gz
emacs-d14bb752ea51331ce2fb459c6ffacd8b11f80bb0.zip
* lisp/emacs-lisp/gv.el (gv-ref, gv-deref): New function and macro.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/emacs-lisp/gv.el18
2 files changed, 22 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7c51b139ec3..e0ff05aa7dc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/gv.el (gv-ref, gv-deref): New function and macro.
4
12012-11-07 Michael Albinus <michael.albinus@gmx.de> 52012-11-07 Michael Albinus <michael.albinus@gmx.de>
2 6
3 * notifications.el (notifications-get-server-information-method): 7 * notifications.el (notifications-get-server-information-method):
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index d6c91539a90..34e29ba1cbd 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -433,6 +433,24 @@ The return value is the last VAL in the list.
433 `(logior (logand ,v ,mask) 433 `(logior (logand ,v ,mask)
434 (logand ,getter (lognot ,mask)))))))))) 434 (logand ,getter (lognot ,mask))))))))))
435 435
436;;; References
437
438;;;###autoload
439(defmacro gv-ref (place)
440 "Return a reference to PLACE.
441This is like the `&' operator of the C language."
442 (gv-letplace (getter setter) place
443 `(cons (lambda () ,getter)
444 (lambda (gv--val) ,(funcall setter 'gv--val)))))
445
446;;;###autoload
447(defsubst gv-deref (ref)
448 "Dereference REF, returning the referenced value.
449This is like the `*' operator of the C language.
450REF must have been previously obtained with `gv-ref'."
451 (declare (gv-setter (lambda (v) `(funcall (cdr ,ref) ,v))))
452 (funcall (car ref)))
453
436;;; Vaguely related definitions that should be moved elsewhere. 454;;; Vaguely related definitions that should be moved elsewhere.
437 455
438;; (defun alist-get (key alist) 456;; (defun alist-get (key alist)