Function: gv--defsetter

gv--defsetter is a byte-compiled function defined in gv.el.gz.

Signature

(gv--defsetter NAME SETTER DO ARGS &optional VARS)

Documentation

Helper function used by code generated by gv-define-setter.

NAME is the name of the getter function. SETTER is a function that generates the code for the setter. NAME accept ARGS as arguments and SETTER accepts (NEWVAL . ARGS). VARS is used internally for recursive calls.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/gv.el.gz
;; (defmacro gv-define-expand (name expander)
;;   "Use EXPANDER to handle NAME as a generalized var.
;; NAME is a symbol: the name of a function, macro, or special form.
;; EXPANDER is a function that will be called as a macro-expander to reduce
;; uses of NAME to some other generalized variable."
;;   (declare (debug (sexp form)))
;;   `(eval-and-compile
;;      (if (not (boundp 'gv--macro-environment))
;;          (setq gv--macro-environment nil))
;;      (push (cons ',name ,expander) gv--macro-environment)))

(defun gv--defsetter (name setter do args &optional vars)
  "Helper function used by code generated by `gv-define-setter'.
NAME is the name of the getter function.
SETTER is a function that generates the code for the setter.
NAME accept ARGS as arguments and SETTER accepts (NEWVAL . ARGS).
VARS is used internally for recursive calls."
  (if (null args)
      (let ((vars (nreverse vars)))
        (funcall do `(,name ,@vars) (lambda (v) (apply setter v vars))))
    ;; FIXME: Often it would be OK to skip this `let', but in general,
    ;; `do' may have all kinds of side-effects.
    (macroexp-let2 nil v (car args)
      (gv--defsetter name setter do (cdr args) (cons v vars)))))