Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!julius.cs.uiuc.edu!zaphod.mps.ohio-state.edu!think.com!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.lang.clos Subject: Re: Defining SETF methods for CLOS methods Message-ID: <1990Dec6.053724.23157@Think.COM> Date: 6 Dec 90 05:37:24 GMT References: <9012051643.AA01507@zaphod.lanl.gov.lanl.gov> <19901205172442.3.BARMAR@OCCAM.THINK.COM> <1990Dec5.212406.20667@arc.ab.ca> Sender: news@Think.COM Distribution: inet Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 35 In article <1990Dec5.212406.20667@arc.ab.ca> mdb@arcsun.arc.ab.ca (Mark Brinsmead) writes: > What is the "officially sanctioned" way of defining a setf method for ONE >SPECIFIC method of a generic function? My reading of the standards >implies that >something of the form: > > (defsetf (find-method ()) ...) > >ought to do it, but the version of PCL I am using (which I thought to be the >most recent!) does not seem to support FIND-METHOD, so I can't experiment. I don't know where you could have read that. DEFSETF doesn't evaluate its arguments, so it doesn't matter whether FIND-METHOD is defined; the first argument to DEFSETF is required to be a symbol. The correct way to define a CLOS SETF function is: (defmethod (setf ) () ...) > What I am trying to do (though its of little relevance) is to define a >write-once slot. Defining it with a :ACCESSOR makes the slot just plain >writable; I want to allow writing ONLY as long as the slot-value is the >default, in this case, NIL. You might want to do this using a BEFORE or AROUND method, so that the default primary method will continue to fill in the slot using the default mechanism. A BEFORE method could be used if you want an error to be signalled if an attempt is made to assign the slot twice; an AROUND method could be more flexible (e.g. just ignore the attempt to reassign, by not calling NEXT-METHOD). -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar Brought to you by Super Global Mega Corp .com