[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fixing our problems with setf
Rules for the macroexpansion of (setf (foo x) y):
(1) If the function-name foo refers to the global function
definition, rather than a locally defined function or macro, and if
there is a setf macro defined for foo, use the setf macro to
compute the expansion.
(2) If the function-name foo is defined as a macro in the
current scope, use macroexpand-1 to expand (foo x) and try again.
(3) If the function-name foo is defined as a special form in
the current scope, signal an error.
(4) Expand into the equivalent of
(let ((#:temp-1 x)
(#:temp-2 y))
(funcall #'(setf foo) #:temp-2 #:temp-1))
Do (1) and (4) together imply that if there is a macro definition for
foo, and there is an flet foo, but no (setf foo) defined, that the
expansion of
(setf (foo ...)...)
uses (funcall #'(setf foo) ...) rather than the macro. This seems wrong
(inconsistent with CLtL ???).
Normally one does not define both a setf function and a setf
macro for the same reading function.
But if a (setf foo) is defined locally, it is always be used, whether or
not foo is defined locally or globally, right???
I think the rule might be stated that if there is no (setf foo) function
AND there is a setf macro, then the macro is used, else the (setf foo)
function is used in the expansion. This is a slightly extended version
of your:
In the absence of any setf macro definition, SETF of a function
expands into a call to the setf function.
But aside from these two glitches (or my misunderstanding), I agree.
danny