Re: Canonical Way to Mask SETF?



Robert Uhl <eadmund42@xxxxxxxxxxxxxxx> writes:

> (defun menu-item (menu)
> (getf menu :title))
>
> (defsetf menu-title (menu) (title)
> `(setf (getf ,menu :title) ,title))
>
> But of course it doesn't work. Any advice on how this needs to be
> written?

One possibility is simply:

(defmacro menu-item (menu) `(getf ,menu :title))

Now both the setter and getter should work as expected. You don't get
(function menu-item), but then again there's clearly no way you can
get (function (setf menu-item)), so maybe that's reasonable.

--
Frode Vatvedt Fjeld
.