Ken Tilton wrote:
> 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.
That is what I actually need. I'm constructing a model with lots of
interdependent instances and I'd like to be able to say, "Ok, I've
created all instances of the model, make it alive." Isn't this what
to-be used to do?
Here's an example.
I have defined a macro called make-system which lets me create family
trees in convenient way. It just creates instances and sets appropriate
fm-parent for each instance. Its lambda list is
(class-name system-name &rest args)
For example, it converts
(make-system b777-aircraft :aircraft)
into
(make-instance 'b777-aircraft :md-name :aircraft).
The &rest 'args' can contain keyword :subsystems which recursively calls
make-system on the rest of the args after that keyword (supplying
:fm-parent in all subsystems). This all is a substitute for what I've
used to accomplish with "(make-instance parent-class :kids (list ...)"
in cells2.0.
;;=============================================
(make-system b777-aircraft :aircraft
:subsystems
(lights :lights
:subsystems
(switch :pass-signs-switch)
(switch :no-smoking-signs-switch)
(b777-flaps-system :flaps-system
:subsystems
(b777-flaps-lever :flaps-lever)
(flaps-indicator :flaps-indicator)
.....)
;;============================================
So, I instantiate all components of an aircraft in this one place.
Now, suppose I have an observer defined on some slot of class 'switch'
(see above) and that the body of the observer depends on
:flaps-indicator component. At the moment when switch
:pass-signs-switch is instantiated, flaps-indicator still does not
exist, so when the observer is called, it fails.
As I said in my previous mail, it seems to be the case of "don't do it
then". :-) The "fix" is to define the observer after the aircraft has
been constructed, so that all its components are available. OTOH, if I
were able to stop the Cells engine, create instances, and then start the
engine, that's what I'd do instead.
Thanks!