[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: around method for make-instance

In article <...> djskrien@COLBY.EDU (Dale J. Skrien) writes:
 > Is there something special about putting methods
 > around the make-instance primary method?
 >  ...
 > But when I define:
 >     (defmethod make-instance :around 
 >                ((x foo) &rest initargs)
 >       (let ((instance (call-next-method)))
 >           (list instance)))
 > then I get:
 > ? (make-instance 'foo)
 >    => #<FOO #x17E44F1>
 > Shouldn't I have gotten:
 >      (#<FOO #x17E44F1>)

Because the argument to make-instance, 'foo, is of type SYMBOL, not of
class FOO!  You would need to have the method specialized on (eql 'foo):

     (defmethod make-instance :around 
                ((x (eql 'foo)) &rest initargs)
       (let ((instance (call-next-method)))
           (list instance)))

Thomas A. Russ,  USC/Information Sciences Institute          tar@isi.edu    
4676 Admiralty Way, Marina del Rey, CA 90292          (310) 822-1511x775