It turns out that while setf compiler-macros now work just fine, they
are basically useless, as
(setf (foo x y) z)
becomes something like
(let ((#:g1 x)
(multiple-value-bind (#:g3) z
(funcall #'(setf foo) #:g3 #:g1 #:g2)))
so while the compiler-macro for (setf foo) gets applied, it really
nevers stands a chance of doing anything sensible...
I *think* some things could be done about this:
1. If the new-values form is independent of the other argument forms,
we don't need to perform any reordering.
Turning our CONSTANTP into FORM-DEPENDENCIES is not all that hard
--- while of course there will be many cases where it won't be
able to tell, but
(form-dependencies '(+ 1 x)) => X, T
is simple enough. Add enough smarts to the CONSTANTP to deal with
inlined functions, and this should catch the vast majority of
common cases -- at least as long as no full calls are involved.
2a. SB-C:PURE-VARIABLE declaration that tells the compiler that
variable is pure, ie. that variable cannot be assigned to after
initial binding. Then, CONSTANTP can return for lexical variables
whose bindings are pure and whose value-forms are constant -- so
setf-macros can detect constantness of arguments despite the
additional binding and use CONSTANT-FORM-VALUE to access it.
2b. Constant argument forms don't need bindings, but can be directly
spliced to the argument list. This is definitely the easiest to
As far as I can tell nothing in the spec prohibits any of these,
but I'm by no means sure.
-- Nikodemus Schemer: "Buddha is small, clean, and serious."
Lispnik: "Buddha is big, has hairy armpits, and laughs."
Get latest updates about Open Source Projects, Conferences and News.