3 ms·
One interesting thing one can do with SETF is define expanders that dive into accessors on "pure" datatypes, copying as needed. Suppose we have a pure cons typ
by pfdietz 2y ago
One interesting thing one can do with SETF is define expanders that dive into accessors on "pure" datatypes, copying as needed.
Suppose we have a pure cons type, call it PCONS, with accessors PCAR and PCDR. Then, the form
(setf (pcar (pcdr x)) y)
turns into (effectively; the actual expansion has temporary variables to avoid duplicating forms)
(progn (setq x (pcons (pcar x) (pcons y (pcdr (pcdr x))))) y)
- amno 2y agoWe need nsetf! :-)