Update of /project/rjain-utils/cvsroot/formulate/examples In directory cl-net:/tmp/cvs-serv9595/examples
Modified Files: simple.lisp Log Message: fix perimeter formula and provide default side lengths
--- /project/rjain-utils/cvsroot/formulate/examples/simple.lisp 2009/11/04 21:41:34 1.2 +++ /project/rjain-utils/cvsroot/formulate/examples/simple.lisp 2009/11/11 08:57:21 1.3 @@ -1,7 +1,8 @@ (in-package :formulate-user)
+;; default is for variables to be formulas (define-formulated-variable *x* 5 - :formulator-class simple-formulator-source) + :formula-p nil)
(define-formulated-variable *y* (expt *x* 2))
@@ -17,14 +18,15 @@ (defgeneric area (shape)) (defgeneric perimeter (shape))
+;; default is for slots to not be formulas --- is this inconsistency good or bad? (defclass square () - ((side :initarg side :accessor square-side) - (perimeter formula-p t :initform (* (my 'side) 2) :reader perimeter) + ((side :initarg side :initform 0 :accessor square-side) + (perimeter formula-p t :initform (* (my 'side) 4) :reader perimeter) (area formula-p t :initform (expt (my 'side) 2) :reader area)) (:metaclass formulated-class))
(defclass circle () - ((radius :initarg radius :accessor circle-radius) + ((radius :initform 0 :initarg radius :accessor circle-radius) (perimeter formula-p t :initform (* (my 'radius) 2 pi) :reader perimeter) (area formula-p t :initform (* (expt (my 'radius) 2) pi) :reader area)) (:metaclass formulated-class))