setf-expanderlet(&rest bindings) &body body ⇒ results
setf-expanderletintroduces local setf-expanders. This opens possibilities for more complex local setf-expanders than can be handled by Common Lisp's built-in support for local setf functions (which must evaluate all their arguments once from left to right and can only accept one new value at a time).
defmacro. The bindings of
setf-expanderlethave much the same semantics as their counterparts in
macrolet, except the job of each expander is to return a setf expansion (5 values), not a normal expansion (a form).
As an example of what
setf-expanderletcan let one accomplish,
with-resolved-placesis trivially implemented in terms of it.
Implementation note: Surprisingly enough, this implementation of
setf-expanderletis written fully portably. As far as I can tell, the only caveat is that the name of the local setf-expander is unconditionally made a local macro. This macro, if used in a non-place context, simply expands to a form that evaluates the subforms and then reads the place.
In contrast, "real" setf-expanders as defined by
define-setf-expanderdon't affect the semantics of the operator in non-place contexts, which is useful if the operator is a function. However, if the original operator is simple enough that it's implemented as a function, you can probably just use a local setf function anyway so I don't think the aforementioned caveat is very important.