Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

defsetf

defsetf( 
s_accessFn 
s_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

s_accessFn

The access function name which setf is expected to handle.

s_updateFn

The name of a function or macro which replaces the value at the place accessed by s_accessFn. The function or macro must accept the same number of arguments as s_accessFn plus one additional argument containing the new value.

Value Returned

setf_<s_accessFn>

A macro which is used in setf.

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
 ⠀
X