[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

An example of where setf does not do what I want.



The inclusion of APPLY as one of the cases handled by SETF (page 96)
was prompted by exactly the case you describe:

(setf (apply #'aref (cons my-array dims)) value)

As I recall, we considered saying that (setf (apply #'aref ...) ...)
was required to work one way or another, but went with this supposedly
more general form instead: in a SETF the first argument to APPLY must be any
function known to SETF whose internal setting function is of a certain
form.

Unfortunately, when all this got written into the manual, we neglected
to say explicitly that AREF was required to be one of those functions
that works in this context (though all the examples indicate that this
is what we had in mind).  So technically, given the current wording of
the manual, it is legal for SETF of APPLY of AREF not to work.  In my
opinion, any Lisp that takes advantage of this loophole is broken, and
the manual should be clarified to require that SETF of APPLY of AREF
must work as you would expect.

Unfortunately, the Spice Lisp code seems to be broken in exactly this
way at present.  I thought we had put in a special check to handle
AREF years ago, but apparently the fix didn't take.  Other
implementations may have caught this bug from us.

-- Scott