From: Glen Whitney
Subject: Common Lisp's SETF feature
Date: 
Message-ID: <2360@husc6.harvard.edu>
Suppose I have a variable, FRED, whose value is a place
descriptor for SETF, like (get 'joe 'eye-color), and I
would like to SETF into the place described by FRED's
value. Is there any nice way of doing this? I couldn't
figure one out. Any help would be appreciated. 
   (I do realize that the method can't be determined 
until run-time because it might differ for
different values of FRED. I'm willing to pay any cost
associated with that. I just don't know any nice means of
telling lisp to do it.)
    Thanks
      --- Glen Whitney

From: Bruce Krulwich
Subject: Re: Common Lisp's SETF feature
Date: 
Message-ID: <991@accuvax.nwu.edu>
In article <····@husc6.harvard.edu>, ·······@endor (Glen Whitney) writes:
> Suppose I have a variable, FRED, whose value is a place
> descriptor for SETF, like (get 'joe 'eye-color), and I
> would like to SETF into the place described by FRED's
> value. Is there any nice way of doing this? I couldn't
> figure one out. Any help would be appreciated. 

I almost break out in hives to say this, but one way would be:

    (eval `(setf ,fred ,<value descriptor>))

but I think that unless you're doing a debugging system or something like that
there must be a way around having to use the interpreter like this.  Are you
sure you haven't made some (bad) design choice that has forced you to do
horrible stuff like this??


Bruce Krulwich
Institute for the Learning Sciences
From: Dan Weinreb
Subject: Re: Common Lisp's SETF feature
Date: 
Message-ID: <407@odi.ODI.COM>
You definitely would need to invoke macro expansion at runtime in
order to do what you are asking for.  So the following solution is
probably as good as any.  Note that this is not incredibly efficient,
but I doubt you can do a whole lot better.  Warning: I have not
debugged this.

(defun setf-var-val (the-symbol new-value)
  (eval `(setf ,(eval the-symbol) ',new-value)))