, -, / . , . Lisp , , , . , setf Lisp , -:
(slot-value vehicle 'speed) ; gets the speed
(setf (slot-value vehicle 'speed) 100) ; sets the speed
setf setter :
(set-slot-value vehicle 'speed 100) ; sets the speed
:
(set-aref 3d-board 100 100 100 'foo) ; sets the board at 100/100/100
, setter . setf.
: setter.
setf . ? . setf getter call .
world-time ; may return the world time
(setf world-time (get-current-time)) ; sets the world time
...
, : setf, push, pushnew, remf,... , .
(defun set-23 (place)
(setf place 23))
, place - . . , , :
(defun set-23 (foo)
(setf foo 23))
foo - . - . - . setf . -, , .
(defmethod set-24 ((vehicle audi-vehicle))
(setf (vehicle-speed vehicle) 100))
vehicle audi-vehicle. , setf .
Lisp ? , :
(defclass audi-vehicle ()
((speed :accessor vehicle-speed)))
:accessor vehicle-speed , .
setf . . setf , Lisp , .
setf: expand:
:
CL-USER 86 > (pprint (macroexpand-1 '(setf (aref a1 10) 'foo)))
(LET* ((
(SETF::\"COMMON-LISP\"\ \"AREF\" #:|Store-Var-10336874|
#:G10336875
#:G10336876))
:
CL-USER 87 > (pprint (macroexpand-1 '(setf a 'foo)))
(LET* ((
(SETQ A
CLOS:
CL-USER 88 > (pprint (macroexpand-1 '(setf (slot-value o1 'bar) 'foo)))
(CLOS::SET-SLOT-VALUE O1 'BAR 'FOO)
:
CL-USER 89 > (pprint (macroexpand-1 '(setf (car some-list) 'foo)))
(SYSTEM::%RPLACA SOME-LIST 'FOO)
, . setf Lisp , .
, , :