Newsgroups: comp.lang.lisp Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!fujiyama!mzaik From: mzaik@ee.eng.ohio-state.edu (Tahsin Mzaik) Subject: Accessing a field of a Lisp structure Message-ID: Date: Wed, 10 Apr 91 19:34:34 GMT Organization: The Ohio State University Dept of Electrical Engineering Distribution: usa Originator: mzaik@fujiyama.eng.ohio-state.edu Hello Lisp experts: I have a common lisp question: I would like to write a macro that can access a particular field in a structure. Example: Let the structure be: (defstruct test a b c) (make-test instance) I would like to wite a macro 'access-field' that I can invoke something like (access-field instance 'a) in order to access field a of the structure. I have tried the following, but it does not work: (defmacro access-field (instance field) '(setq (test-,field ,instance) any-value) ) Any ideas? Thanks for any reply.