[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: defining a setter function with gv.el
From: |
Ivan Kanis |
Subject: |
Re: defining a setter function with gv.el |
Date: |
Mon, 27 Aug 2012 20:10:53 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> So I think what you mean is that you want
>
> (my-function) => tree
> (setf (my-function) 'shrub)
> (my-function) => shrub
Yup exactly.
> As for you specific question, I suspect that it is answered in the last
> few lines of gv.el:
>
> ;;; Vaguely related definitions that should be moved elsewhere.
>
> ;; (defun alist-get (key alist)
> ;; "Get the value associated to KEY in ALIST."
> ;; (declare
> ;; (gv-expander
> ;; (lambda (do)
> ;; (macroexp-let2 macroexp-copyable-p k key
> ;; (gv-letplace (getter setter) alist
> ;; (macroexp-let2 nil p `(assoc ,k ,getter)
> ;; (funcall do `(cdr ,p)
> ;; (lambda (v)
> ;; `(if ,p (setcdr ,p ,v)
> ;; ,(funcall setter
> ;; `(cons (cons ,k ,v)
> ,getter)))))))))))
> ;; (cdr (assoc key alist)))
>
Good grief, does it have to be so complicated for such a simple need?
--
Ivan Kanis
http://ivan.kanis.fr
O Love, O fire! Once he drew
With one long kiss my whole soul through
My lips, as sunlight drinketh dew.
-- Alfred, Lord Tennyson