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

reinitialization protocol



Here is some pseudo code for the re-initialization protocol that Danny
and I worked out.

;;;; The re-initialization protocol.

(defmethod reinitialize-instance ((object standard-object) &rest reinit-args)
  (let* ((arglist (list object))
	 (acceptable-args
           (union
	     (method-keyword-arguments #'initialize-instance arglist)
	     (method-keyword-arguments #'reinitialize-instance arglist)
	     (class-all-slot-initargs (class-of object)))))
    ;; check the keyword arguments
    (zl:loop (key in reinit-args by cddr)
       (or (member key acceptable-args) (error ...)))
    ;; now initialize the instance
    (apply #'initialize-instance object
				 :allow-other-keys 't
				 (default-init-args object reinit-args))
    ;; update all dependents
    (loop (dep in (all-dependents object))
	  (apply #'update-dependent object dependent reinit-args))
    nil))

;;;
;;; Generic functions for managing the dependents of an object.  This is
;;; part of the instance re-initialization protocol.  How dependents are
;;; stored is implementation dependent.  Some subclasses of
;;; standard-object which know that they are in fact going to have lots
;;; of dependents may want to replace this triad of methods with methods
;;; which actually store the value in a slot.
;;;
(defmethod add-dependent ((object standard-object)
			  (dependent standard-object))
  ;; Add dependent as a dependent of object.  
  )

(defmethod remove-dependent ((object standard-object)
			     (dependent standard-object))
  ;; Remove dependent as a dependent of object.
  )

(defmethod all-dependents ((object standard-object))
  ;; Returns the list of all dependents of the object.
  )
-------