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

get-setf-method



In the proposed clarifications for CLtL, for page 107, GLS states
that GET-SETF-METHOD should not do macroexpansion, and
that it should be called with an already expanded form.
The purpose of this change is to avoid having to make GET-SETF-METHOD
take an &environment parameter, since MACROEXPAND needs it.

He says "in most contexts the usage should be
(GET-SETF-METHOD (MACROEXPAND form env))."  This seems
incorrect to me, as there may be a setf method defined on an intermediate
expansion of the macro, which should take precedence over the macroexpansion.
In order to correct this problem, each function which called GET-SETF-METHOD
would have to repeatedly call it with MACROEXPAND-1 until there were no
longer any macros to expand, or GET-SETF-METHOD found a setf method.
What would GET-SETF-METHOD return if it didn't find a setf method?

Here is an example of the problem:

(defsetf foo boat)
(defmacro foobar (x) `(foo ,x))
(defmacro foo (x) `(car ,x))
(setq x '(a . b))

(setf (foobar x) 3) ; this will expand to something equivalent to
                    ; (setf (car x) 3) instead of calling boat as
                    ; the update function.

In other words, it missed the boat!

In looking at the current SPICE sources, I see that GET-SETF-METHOD does
take an environment, and MACROEXPAND-1 is called repeatedly, rather than
MACROEXPAND.  Due to the discrepency between the SPICE code and the
clarifications list, I assume that either no consensus has been reached,
or some decision has been made of which I am not aware.

	John Diamant
	Hewlett Packard Company   diamant%hpfclp@hplabs.arpa