[rjain-utils-cvs] CVS formulate/src

rjain rjain at common-lisp.net
Fri Dec 25 20:57:08 UTC 2009


Update of /project/rjain-utils/cvsroot/formulate/src
In directory cl-net:/tmp/cvs-serv27653/src

Modified Files:
	formulate.lisp 
Log Message:
define classes using mixins


--- /project/rjain-utils/cvsroot/formulate/src/formulate.lisp	2009/11/19 00:44:14	1.5
+++ /project/rjain-utils/cvsroot/formulate/src/formulate.lisp	2009/12/25 20:57:08	1.6
@@ -24,7 +24,7 @@
       (error unbound-condition :name cell-name)))
 
 ;;;
-;;; *** SIMPLE FORMULATOR SOURCE
+;;; *** SIMPLE FORMULATOR SOURCE ***
 ;;;
 
 (defclass simple-formulator-source ()
@@ -59,7 +59,7 @@
     result))
 
 ;;;
-;;; FORMULA FORMULATOR SINK
+;;; *** FORMULA FORMULATOR SINK ***
 ;;;
 
 (defclass formula-formulator-sink ()
@@ -80,18 +80,18 @@
   (slot-boundp formulator 'formula))
 
 ;;;
-;;; *** LAZY FORMULATOR SINK
+;;; *** LAZY FORMULATOR ***
 ;;;
 
-(defclass lazy-formula-formulator-sink (formula-formulator-sink)
+(defclass lazy-formulator-mixin ()
   ((source :initarg source
            :initform (make-instance 'simple-formulator-source)
            :accessor formulator-source
            :documentation "FORMULATOR-SOURCE that contains the cached
            value and propagates changes to sinks that refer to this
            formulator's parent cell."))
-  (:documentation "FORMULATOR-SINK implementation that lazily recomputes
-  and caches the formula's value."))
+  (:documentation "Mixin that lazily recomputes and caches the formula's
+  value."))
 
 (defmethod formulator-dependents ((formulator lazy-formula-formulator-sink))
   (formulator-dependents (formulator-source formulator)))
@@ -99,8 +99,10 @@
 (defmethod (setf formulator-dependents) (new-value (formulator lazy-formula-formulator-sink))
   (setf (formulator-dependents (formulator-source formulator)) new-value))
 
-(defmethod formulator-value ((formulator lazy-formula-formulator-sink)
-                             &optional cond cell)
+(defmethod formulator-value :around ((formulator lazy-formula-formulator-sink)
+                                     &optional cond cell)
+  ;; should this be an around method or should I mandate ordering of
+  ;; mixins?
   (let ((source (formulator-source formulator)))
     (if (formulator-value-validp source)
         (let ((*formulating* nil))
@@ -119,14 +121,23 @@
     ((sink lazy-formula-formulator-sink) source new-value old-value)
   (formulator-invalidate sink))
 
+(defclass lazy-formula-formulator-sink (lazy-formulator-mixin
+                                        formula-formulator-sink)
+  ()
+  (:documentation "FORMULATOR-SINK implementation that lazily recomputes
+  and caches the formula's value."))
+
 ;;;
-;;; DYNAMIC-FORMULATOR
+;;; *** DYNAMIC FORMULA FORMULATOR ***
 ;;;
 
-(defclass dynamic-formulator (lazy-formula-formulator-sink)
+(defclass dynamic-formula-formulator-mixin (formula-formulator-sink)
   ())
 
 (defmethod (setf formulator-value) (new-value (formulator dynamic-formulator))
   (setf (formulator-formula formulator) new-value
         (formulator-formula-function formulator) (compile nil `(lambda () ,new-value)))
   (formulator-invalidate formulator))
+
+(defclass dynamic-lazy-formula-formulator (lazy-formula-formulator-sink dynamic-formula-formulator-mixin)
+  ())





More information about the Rjain-utils-cvs mailing list