Function: gv-ref

gv-ref is an autoloaded macro defined in gv.el.gz.

Signature

(gv-ref PLACE)

Documentation

Return a reference to PLACE.

This is like the & operator of the C language. Note: this only works reliably with lexical binding mode, except for very simple PLACEs such as (symbol-function 'foo) which will also work in dynamic binding mode.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/gv.el.gz
;;; References

;;;###autoload
(defmacro gv-ref (place)
  "Return a reference to PLACE.
This is like the `&' operator of the C language.
Note: this only works reliably with lexical binding mode, except for very
simple PLACEs such as (symbol-function \\='foo) which will also work in dynamic
binding mode."
  (let ((code
         (gv-letplace (getter setter) place
           `(cons (lambda () ,getter)
                  (lambda (gv--val) ,(funcall setter 'gv--val))))))
    (if (or lexical-binding
            ;; If `code' still starts with `cons' then presumably gv-letplace
            ;; did not add any new let-bindings, so the `lambda's don't capture
            ;; any new variables.  As a consequence, the code probably works in
            ;; dynamic binding mode as well.
            (eq (car-safe code) 'cons))
        code
      (macroexp-warn-and-return
       "Use of gv-ref probably requires lexical-binding"
       code))))