(SETF (#'named-function variable) value) 
Author Message
 (SETF (#'named-function variable) value)

Hi folks,

There's something I'm trying to get LISP to do, but I don't know how do
to it
or whether it's even possible.

I know that I can use SETF to modify the contents of a _slot_ in an
object.  For
example,  I can do

(defclass name ()
  ((first :accessor first)
   (last :accessor last)))

and then for an instance of name, do this:

(setf (first x) "Cecil")

Here's what I'm trying to do, but can't

(setf key-accessor #'(lambda (x) (first x)))
(setf (key-accessor x) "Newname")

I understand why this doesn't work, because the form (key-accessor x) gets
evaluated completely to the value of the slot.  What I want is someway of
getting at the slot itself, without having to hardwire the accessor
"first" into
my code, which ideally should handle objects other than names.

Please email me any insights on this.  Thanks a lot!
Cecil Huang
|                                              |  

|  Section on Medical Informatics at Stanford  |
|  Rockwell Palo Alto Science Center           |
|  Leave message at (415) 325-6460             |

Fri, 02 May 1997 15:25:23 GMT  
 [ 1 post ] 

 Relevant Pages 

1. How to write a macro for printing variable's name and its value

2. (setf <name>) function designator

3. SETF methods and SETF functions

4. values of variable variable-names

5. Trouble using variables for function names in function declarations

6. Trouble using variables for function names in function declarations


8. Using a variable name for a variable name??

9. Name valid outside function, but error name inside function

10. How update variable values by calling secondary functions ?

11. Get Global Variable Value from C++ function?

12. function name in variable?


Powered by phpBB® Forum Software