Comment

Comment by pfdietz

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)

parent pfdietz 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton