[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Colormap, `createEnd' not implemented ... [Re: your mail]
From: |
Alex Lancaster |
Subject: |
Re: Colormap, `createEnd' not implemented ... [Re: your mail] |
Date: |
20 Apr 1998 01:21:38 -0600 |
>>>>> "PT" == Pietro Terna <address@hidden> writes:
PT> A delayed question:
KC> PS: Its my understanding that now the call to `getZone' may also
KC> be unnecessary since Swarms can now be used as Zones, is that
PT> ^^^^^^^^^^^^^^^^^^^^^^^^
KC> true?
>> Yep.
PT> What does this mean? Have we to change from "...: [self
PT> getZone]]" to "...: self] all "create" lines; are there reasons to
PT> prefer one form or the other? I'm develpoing heavy apps and I
PT> would prefer to wirte a stanel code for the future.
The rule is simple:
1. You should use the "...: self]" form of creation *only* when the
object that you are creating these objects *within* is itself a Swarm
(or a subclass of a Swarm - in other words when creating objects
within a ModelSwarm or an ObserverSwarm).
2. At all other times you should still use the "...: [self getZone]"
form. In other words, when creating objects within an ordinary
SwarmObject (not a Swarm!) you still need to get the Zone of that
object.
The reason for this, is that a Swarm is a special kind of object,
which is intended to form the basis of segregated storage allocation,
and in fact is also a "Zone". An ordinary SwarmObject does not have
this property. Since all SwarmObjects (or subclasses thereof) must
have been created at the top level in a Model or ObserverSwarm - then
the [self getZone] call returns the Zone (in other words - the Swarm)
in which that object was created. In a future parallelised version of
Swarm - the notion of a Swarm as a storage Zone will come into its
own.
As an example, this means that you use the first kind of Zone
allocation, in the following way:
In the .h file, you might have:
@inteface ModelSwarm : Swarm {
id agentList;
}
[....]
-buildObjects;
@end
In the .m file, you have:
@implementation ModelSwarm
[...]
- buildObjects
{
[...]
agentList = [List create: self];
[...]
}
@end
*But*, if you are creating an object within an agent inside the
agentList created above, you would use the [self getZone] as an
argument to the create/createBegin function.
There are reasons to prefer the "... create: self]" version, one is
that it means that you never need to explictly create or refer to a
Zone (except at the very top level - i.e. in the main.m file). So in
the heatbugs app file "HeatbugsObserverSwarm.m" you currently have:
-buildObjects
{
modelZone = [Zone create: [self getZone]];
modelSwarm = [ModelSwarm create: modelZone];
[...]
}
You can now replace these two lines with one line:
modelSwarm = [ModelSwarm create: self];
Remember that you are creating a "Swarm" within a "Swarm"!
I hope this makes it a little clearer. The most recent distribution
of the tutorial application has been changed to following these
conventions, so have a look at any of those demo apps to clarify you
thinking on this coding issue.
Regards,
--- Alex
--
Alex Lancaster | e-mail: address@hidden
Swarm Developer | web: http://www.santafe.edu/~alex
Santa Fe Institute | tel: +1-(505) 984-8800
------------------------------------------------------------------
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
==================================