[EMAIL PROTECTED] writes: > I'd like to setf a "place" which is retrieved indirectly with a funcall > call: > > > (defstruct my > a b) > > (setq myinstance (make-my)) > > (setf (my-a myinstance) 33) ; this works > > (setq my-get-func 'my-a) > (setf (funcall my-get-func myinstance) 33) > ; this doesn't work > ; "No setf-method known for funcall"
Write a defsetf-er for funcall! (require 'cl) (defmacro with-gensyms (syms &rest body) `(let ,(mapcar (lambda (s) `(,s ',(gensym (symbol-name s)))) syms) ,@body)) (define-setf-method funcall (fun &rest args) "setf-method for (funcall fun args...)" (let* ((vfun (eval fun)) (vexp (get-setf-method `(,vfun ,@args)))) (message "\n%S\n" vexp) (when (null vexp) (error "There is no defsetf for %s in %S" vfun (cons fun args))) vexp)) (progn (setf x (cons :a :b)) (setf f (function cdr)) (setf (funcall f x) 1) (insert (format "--> %S\n" x)) (dolist (f (list (function car) (function cdr))) (setf (funcall f x) 2)) (insert (format "--> %S\n" x))) --> (:a . 1) --> (2 . 2) -- "By filing this bug report you have challenged the honor of my family. Prepare to die!" _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs