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

Re: Method combination

This message contains a note of interest to all PCL users.

    Date: Fri, 17 Mar 89 16:30 EST
    From: Richard Zippel <rz@natasha.cs.cornell.edu>

    I must be confused or I've missed some thing in the release notes that I
    should have seen.  I'm trying to include some code that runs when an
    instance of a class is created (using the CLOS style initialization
    protocol).  If I define an class as follows, and create it with 
    (pcl:*make-instance 'foo), FOO-INITIALIZED is not printed.

    (defclass foo () ())

    (defmethod *initialize-instance :after ((object foo) &rest ignore)
      (print 'foo-initialized))

This works properly for me.  The only thing I can think of is that you
might be getting screwed by package problems.  Maybe your defmethod on
*initialize-instance is defining a method on a generic function of that
name in your package.  One thing that makes me suspect this is that you
package qualify *make-instance but not *initialize-instance.  Neither of
those symbols is actually exported from the PCL package.

A note of general interest.  The names of the initialization functions
will be switched to conform to the specification in the next release.  A
simple way to start using the correct names for these generic functions
now is shown below.  This scheme has the nice property that you don't
have to fix all of your code at once, the old name and new name will
refer to the same generic function object.

(in-package "MY-PACKAGE" :use "PCL")

(eval-when (compile load eval)
  (setf (symbol-function 'make-instance) #'pcl::*make-instance
	(symbol-function 'initialize-instance) #'pcl::*initialize-instance))