common lisp - CLOS: convert symbol to accessor -
this real beginner question guess, couldn't find answer here. problem: set value of slot of class so:
(setf (accessor class) value)
i wrote small function this:
(defun set-class-slots (class slot value) (setf (slot class) value))
i'm using in loop, in i'm iterating through 2 lists (slots (a list of symbols) , values (a list of numbers)) , set several slots of instance values.
(loop slot in slots value in values (set-class-slots <myclass> slot value) )
the error i'm getting is:
"undefined operator (setf slot) in form ((setf slot) #:|store-var-773597|#:g773598."
i think problem setf in function not use value provided input arg. 'slot' reads 'slot' operator.
i tried different things, symbol-function, funcall, etc. don't know anymore - don't understand going wrong.
any appreciated.
thanks, marleynoe
you can use fdefinition
function value of (setf xxx)
function:
(defun set-class-slots (class slot value) (funcall (fdefinition `(setf ,slot)) value class))
Comments
Post a Comment