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

Re: Declaration of valid initialization args.

>> I don't think this is correct.  COMPUTE-APPLICABLE-METHODS only needs to
>> see a satisfactorily rich subset of the total effective methods for that
>> generic-function.  I think it will force the calculation (or re-calculation)
>> of the current effective methods when necessary, regardless of whether or
>> not the function has been 'called'.
Jon, I am not sure what is meant by "a satisfactorily rich subset", but 
here is an example where PCL does not keep proper account of a generic 
function's applicable methods:

(defclass c1 ()())
(defmethod initialize-instance :after ((object C1) &rest initargs &key c)
  (declare (ignore initargs))
  (format t "The value of c is ~A.~%" c))

(compute-applicable-methods #'initialize-instance
			    (list (pcl::class-prototype (find-class 'c1)))) 
--> (#<Standard-Method INITIALIZE-INSTANCE (OBJECT) 31550631>)

;;; Also notice:
(make-instance 'c1 :c 10) 
--> Error: Invalid initialization argument :C for class C1

;;; Yet after initialize-instance has been called once, everything is fine.
(initialize-instance (allocate-instance (find-class 'c1)) :c 10)
The value of c is 10.
-->#<C1 32757001>

(compute-applicable-methods #'initialize-instance
			    (list (pcl::class-prototype (find-class 'c1)))) 
--> (#<Standard-Method INITIALIZE-INSTANCE :AFTER (C1) 32647601> 
#<Standard-Method INITIALIZE-INSTANCE (OBJECT) 31550631>)

(make-instance 'c1 :c 'working)
The value of c is WORKING.
-->#<C1 32774361>

Any suggestions, fixes, etc., would be most welcome.
Darrell Shane