[cells-devel] Cells: Controlling the way kids are added to a parent ...

Kenny Tilton kennytilton at optonline.net
Thu Oct 30 16:07:32 UTC 2008


Frank Goenninger wrote:
> Hi -
> 
> I want to control if a kid is added to a parent based on the execution  
> of a check function. The check function is supposed to throw an  
> condition when the check fails.
> 
> Current use case:
> 
> Control which classes of kids are added to a parent. I do have a model  
> of class BOM (bill of material) that only can accept classes Assembly  
> and Part as kids.
> 
> I found two places at which I could insert a call to the check function:
> 
> function fm-kid-add (higher level interface)
> function fm-kid-insert (lower level interface)
> 
> Question now is: Why would one be better than the other?
> 
> Idea here is based on adding a new slot to class family:
> 
> (defmodel family (model)
>   ((.kid-slots :cell nil
>      :initform nil
>      :accessor kid-slots
>      :initarg :kid-slots)
>    (.kids :initform (c-in nil) ;; most useful
>      :owning t
>      :accessor kids
>      :initarg :kids)
>    (registry? :cell nil
>      :initform nil
>      :initarg :registry?
>      :accessor registry?)
>    (registry :cell nil
>      :initform nil
>      :accessor registry)
>    ;; added: frgo, 2008-10-30    -----
>    (kid-add-control-hook :cell nil
>                          :initform nil
>                          :initarg: kid-add-control-hook)))
> 
> and then do run the check functions that have been added to the  control 
> hook (= list of functions to be funcalled).
> 
> Right approach? Any comments? (It works but I'd like to know if am on  
> the right track).
> 
> Thanks for feedback.

My purely engineer's reaction is that (setf .kids) is the official 
gateway to that slot. I actually forgot about those "fm" functions. Of 
course if /you/ are consistent in their use you should be OK, but how 
about an :around method on (setf .kids) where you check before calling 
call-next-method to complete the operation?

If you need it to work for kids computed by rules, that might have to be 
(setf cells::md-slot-value) further specialized with (slot-name (eql 
'.kids)), but I guess we are not talking about this since you are 
thinking the "fm" functions are a possible solution.

hth, kenny




More information about the cells-devel mailing list