🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #33

Re: [wwinston@Athena.MIT.EDU: having a tiny prob with CLOS - comp.lang.lisp #7889]

#33
From: kanderso
Date: Tue, 11 Aug 1992 13:30
82 lines
3260 bytes
  To: comp.lang.clos@cis.ohio-state.edu
  Date: Tue, 11 Aug 1992 19:41:46 GMT
  Organization: The Ohio State University Department of Computer and Information Science
  From: Whitney Winston <wwinston@speckle.ncsl.nist.gov>
  Sender: commonloops-request@cis.ohio-state.edu
  Subject: [wwinston@Athena.MIT.EDU: having a tiny prob with CLOS - comp.lang.lisp #7889]
  
  
  In article <CHYDE.92Aug10150355@pecos.ads.com>, chyde@pecos.ads.com (Clinton Hyde) writes:
  |> 
  |> i have a method I want to remove. to do so, I need to find it with
  |> find-method, but i haven't been able to figure out what FIND-METHOD
  |> really wants as args.
  |> 
  |> here's CLtL2:
  |> 
  |> (find-method generic-fn qualifiers specializers)
  |> 
  |> here's an example:
  |> 
  |> (find-method (ensure-generic-function my-method-name) NIL '(t))
  
  The problem is that find-method is looking for a list of classes for
  specializers....
  
  (find-method (fdefinition 'my-method-name) nil `(,(find-class 't)))
  
  should handle it.... fdefinition from CLtL2...
  however Lucid 4.0.2 uses clos-sys:function-from-name
  
Actually, there seems to be a CLOS-SYSTEM::FDEFINITION you could import
into your package.

  > (defmethod my-method-name (arg) 'foo)
  #<Standard-Method MY-METHOD-NAME (T)>
  
  > (defmethod my-method-name ((arg symbol)) 'bar) 
  #<Standard-Method MY-METHOD-NAME (SYMBOL)>
  
  These are two random methods.
  
  > (my-method-name 'hi)
  BAR
  
  Now, the method specializing on t and on symbol can each be 
  found as following:
  
  > (find-method (clos-sys:function-from-name 'my-method-name) 
  	       nil 
  	       `(,(find-class 't)))
  #<Standard-Method MY-METHOD-NAME (T)>
  
  
  > (find-method (clos-sys:function-from-name 'my-method-name) nil `(,(find-class 'symbol)))
  #<Standard-Method MY-METHOD-NAME (SYMBOL)>
  
  
  The method specializing on symbol can be removed as follows:
  
  > (remove-method (clos-sys:function-from-name 'my-method-name)
                   (find-method (clos-sys:function-from-name 'my-method-name) 
                                nil 
                                `(,(find-class 'symbol))))
  #<Standard-Generic-Function MY-METHOD-NAME (1)>
  
  This removes the method specializing on symbol as shown below.
  
  > (my-method-name 'hi)
  FOO
  
You could also try:

(defun remove-method-or-spec (method-or-spec)
  (multiple-value-bind (gf method function)
      (clos-system::parse-method-or-spec method-or-spec)
    (declare (ignore function))
    (remove-method gf method)))  
  
so (remove-method-or-spec '(method my-method-name (symbol))) should work.
Unfortunately, it uses an internal function.

k
Technical Details
Message-ID: <9208112135.AA26952@news.cis.ohio-state.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!bbn.com!kanderso
References: <9208111941.AA14897@speckle.ncsl.nist.gov>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.clos
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!bbn.com!kanderso
From: kanderso@bbn.com
Subject: Re: [wwinston@Athena.MIT.EDU: having a tiny prob with CLOS - comp.lang.lisp #7889]
Message-ID: <9208112135.AA26952@news.cis.ohio-state.edu>
Sender: daemon@cis.ohio-state.edu
Organization: The Ohio State University Department of Computer and Information Science
References: <9208111941.AA14897@speckle.ncsl.nist.gov>
Date: Tue, 11 Aug 1992 13:30:09 GMT
Lines: 82