Article View: comp.lang.clos
Article #11passing accessors to functions
From: Eric Peterson x7644
Date: Thu, 29 Oct 1992 21:52
Date: Thu, 29 Oct 1992 21:52
30 lines
1654 bytes
1654 bytes
In article <Bwun61.E1q@world.std.com> jbk@world.std.com (Jeffrey B Kane) writes:
Jeffrey> I have a common function that can act on any of a number of
Jeffrey> slots of a given class. How can I define a function such that
Jeffrey> I can pass it an accessor, the class instance, and the arguments
Jeffrey> something like:
Jeffrey> (defun do-proc (anAccessor aclass arg)
Jeffrey> (setf (anAccessor aclass) arg))
(defun do-proc (anAccessor object arg)
(funcall (fdefinition `(setf ,anAccessor))
arg
object))
should do the trick.
Your Common Lisp may not yet support fdefinition.
Eric Peterson (speaking for myself)
Systems Research and Applications
2000 15th Street North
Arlington, VA 22201
USA
peterson@sra.com
(703) 558-7644
Fax: (703) 558-4723
Technical Details
Message-ID:
<9210292152.AA06961@verdi.iisd.sra.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!ogicse!usenet.coe.montana.edu!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sra.COM!petersonReferences:
<1cnnvlINNbci@early-bird.think.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!usenet.coe.montana.edu!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sra.COM!peterson From: peterson@sra.COM (Eric Peterson x7644) Newsgroups: comp.lang.clos Subject: passing accessors to functions Message-ID: <9210292152.AA06961@verdi.iisd.sra.com> Date: 29 Oct 92 21:52:25 GMT Article-I.D.: verdi.9210292152.AA06961 References: <1cnnvlINNbci@early-bird.think.com> Sender: daemon@cis.ohio-state.edu Organization: The Ohio State University Department of Computer and Information Science Lines: 30