[Sorry if folks have seen this before, but I haven't, so not sure what is going on. - kt]
---------- Forwarded message ---------- From: Ken Tilton kentilton@gmail.com Date: May 9, 2007 5:12 PM Subject: Re: [cells-devel] How to delay evaluation of defobserver? To: Josip Gracin gracin@tel.fer.hr
Not sure what is going on. I sent this to the list and you earlier from another mail account and apparently neither got thru. Trying again direct from google mail. Saw your second note. Nah, I would do anything with load order. But this is a design question, which means it cannot be answered in the abstract (which is what I cover below). kt
Josip Gracin wrote:
Hello!
I've successfully ported my application from cells2.0 to Cells3. Cells3 looks very nice indeed. When needed, I've used c_? to delay evaluation and it worked great. However, I also have some observers defined with defobserver and I'd like them to be lazily evaluated because they depend on some not-yet-created instances. Is there a way to do this?
You might have to provide an example, distilled from your application if the whole thing would be too much. Are you saying obersvers are getting called even before the lazy cell got kicked off? Or do you mean, OK, the lazy cell gets kicked off when expected, but now I further want to defer the observer running? Or is this unrelated to lazy cells? ie, You have a normal cell but you want the observer deferred? But then, OK, how do you indicate when the laziness ends and the observer should fire? Presumably you want a rule X that terminates laziness and activates an observer. If so, you could just code up:
(defobserver ..... (when X ;; in your case, (fm-includes self <whavtever>) <stuff that depends on whatever>))
Depending on the design, you might also consider having a Cell that says "OK, now the model has reached this state", part of which is determined by these other instances coming into existence. Then you either hang your observer off that new state variable or check that state variable in the observer.
kt