As mentioned on IRC, this is not conforming MOP code: here you
instantiate MY-CLASS, then you define methods that are applicable to
objects of MY-CLASS; however, "Portable methods on specified generic
functions specialized to portable metaobject classes must be defined
before any instances of those classes (or any subclasses) are created,
either directly or indirectly by a call to make-instance." The main
workaround for you is I think to use (find-class 'my-object nil) in your
initialize-instance method.
That said, I was able to reduce this to a test case which I think is
legal MOP code and fails in the same way:
Hi,
status confirmed
importance medium
tags clos mop pcl
done
Lars Rune Nøstdal <email address hidden> writes:
> (defclass my-object () superclasses) slot-value- using-class ((class my-class) (object my-object) eslotd) method) ))
> ((id :type integer :reader id-of))
> (:metaclass my-class))
>
> [...]
> (defmethod initialize-instance ((class my-class) &rest initargs &key name direct-
> (defmethod sb-mop:
> (if nil
> (setf (slot-value object 'id) 42)
> (call-next-
As mentioned on IRC, this is not conforming MOP code: here you
instantiate MY-CLASS, then you define methods that are applicable to
objects of MY-CLASS; however, "Portable methods on specified generic
functions specialized to portable metaobject classes must be defined
before any instances of those classes (or any subclasses) are created,
either directly or indirectly by a call to make-instance." The main
workaround for you is I think to use (find-class 'my-object nil) in your
initialize-instance method.
That said, I was able to reduce this to a test case which I think is
legal MOP code and fails in the same way:
(defclass my-class (standard-class) validate- superclass slot-value- using-class call-next- method) ))
())
(defmethod sb-mop:
((class my-class) (super-class standard-class))
t)
(defvar *foo*)
(defmethod sb-mop:
((class my-class) (object standard-object) eslotd)
(if *foo*
(setf (slot-value object 'id) 42)
(
(defclass my-object ()
((id :type integer :reader id-of))
(:metaclass my-class)))
(defclass test (my-object)
((a :reader test-a))
(:metaclass my-class))
I've Cced this to Pascal to ask him to check that the above is actually
legal MOP; in parallel, I'm working on a diagnosis and possible cure for
SBCL.
Cheers,
Christophe