Skip to content
Snippets Groups Projects
Commit dff333a3 authored by rtoy's avatar rtoy
Browse files

Fix for update-dependent on gfs, from Gerd Moellman, 2005-06-26:

This is for one of Bruno's bug reports.  For example,

(defclass upd-history ()
  ((history :initform ())))

(defmethod update-dependent ((gf generic-function) (history upd-history)
			     &rest args)
  (push args (slot-value history 'history)))

(defun history-event-list (history)
  (mapcar (lambda (event)
	    (mapcar (lambda (x)
		      (if (typep x 'method)
			  (list 'method (mapcar #'class-name
						(method-specializers x)))
			  x))
		    event))
	  (reverse (slot-value history 'history))))

(let ((hist (make-instance 'upd-history)))
   (defgeneric upd0 (x))
   (add-dependent #'upd0 hist)
   (defmethod upd0 ((x integer)))
   (history-event-list hist))
=>  ((add-method (method (integer)))))

But, instead of the above expected result, it produces

=>  (nil (add-method (method (integer)))))

The nil is from a reinitialize-instance of the gf, which is triggered
by load-defmethod calling ensure-generic-function, which in turn calls
ensure-generic-function-using-class on the existing gf, which finally
calls reinitialize-instance.

I'm not 100% sure if this is correct or not.  My reading of CLHS/MOP
is that this is at least not forbidden.  Opinions?

	* src/pcl/methods.lisp (real-add-method, update-gf-dependents):
	New function.
	(real-add-method, real-remove-method): Call it.
	(reinitialize-instance) <:around standard-generic-function>:
	Update dependent objects.

	* src/pcl/std-class.lisp (update-dependent): New default method.
parent 6fb3b96a
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment