defsetf
defsetf(s_accessFns_updateFn) =>setf_<s_accessFn>
Description
defsetf is a macro that allows you to specify an update function to use when setf() is called with a place using a given access function. It creates a macro with the prefix setf_ which is used by setf to update a value at the place given by s_accessFn().
Arguments
Value Returned
Examples
; a personal CAR function to distinguish from the built-in car
defun(CAR (x) car(x))
; update function which replaces the car of the list with a new value
defun(SETCAR (x new)
car(rplaca(x new))
)
defsetf(CAR SETCAR)
test_ls='(1 2 3 4 5 6)
; use := operator which is equivalent to setf()
CAR(test_ls) := 10
assert(test_ls == '(10 2 3 4 5 6))
Related Topics
Function and Program Structure
Return to top