[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Alternative Proposal for class updating
The follwoing is based on suggstions made at the meeting by Gabriel, Dussud and
Moon. It is still a sketch. If it seems about right I will send a more complete
writeup. It replaces the class specific generic functions
It replaces the . I want to consider the following as a replacement for
update-class, propagate-class-update, and update-class-locally with some general
mechanisms that have wider applicability. These include a facility for
reinitialization, a facility for recording dependents for a specific object, and
a protocol for updating those dependents.
The generic functions used are:
Reintialization:
reinitialize-instance (object &rest reinit-args)
This generic function is intended to initialize again the object. The default
method augments the given reinit-args using default-initargs, checks the
arguments, and calls initialize-instance. It then updates any dependents
method-keyword-arguments (generic-function list-of-arguments)
This generic function provides an facility to help users to write code for
checking legality of keyword arguments.
Recording dependencies.
add-dependent(object dependent &key)
remove-dependent(object dependent &key)
all-dependents(object)
These three generic functions allow the recording of dependencies. Nothing is
specified about what the dependencies are.
The real work is done here:
update-dependent(object dependent &key)
-----
Here are some sketches of methods:
(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
(loop (key in reinit-args by cddr)
(or (member key acceptable-args) (error ...))
;;; now initialize the instance
(apply #'initialize-instance
object
(default-init-args object reinit-args)
;;; update all dependents
(loop (dep in (all-dependents object))
(apply #'update-dependent object dependent reinit-args))
object)
(defmethod update-dependent
((class standard-class) (dependent standard-class)
&key direct-superclasses direct-slots direct-options)
;;; mark-inheritance as unfinalized,
;;; potentially make-instances-obsolete.)
(defmethod finalize-inheritance ((class standard-class))
;;; compute-cpl
;;; compute-slots
;;; add us as dependent to all classes on
;;; class-precedence-list. Note that this includes us.
;;; mark as finalized.)
(defmethod reinitialize-instance :before
((class standard-class)
&key direct-superclasses direct-slots direct-options)
;;; unhook old direct-subclass pointers and add new ones
;;; undefine old accessors that are no longer needed)