Get the latest tech news
My mental model of setf was wrong
I realised recently that I’ve been thinking about setf all wrong. Lisp lets programs define new setf forms for assignment.
We can’t do this with defgeneric, for broadly the same reasons as why we couldn’t use defun above, so we have to go backstage and programmatically define the generic function. But the names setf synthesises aren’t recognised by defun and defgeneric, and so can’t easily cause capturing – although they are recognised by defmethod, which lets us define the specialised methods “as normal” even though the other parts of the process have to happen backstage. They’re usually thought of as part of CLOS, but they actually have little explicit relationship to class and objects at all, and have been woven all through Lisp to build flexible code structures.
Or read this on Hacker News