swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help!: of Swarm, Objective-C and gdb


From: Eric Werk
Subject: Re: Help!: of Swarm, Objective-C and gdb
Date: Wed, 03 Mar 1999 12:28:37 +0100

Hi William

What a lot of good questions! I hope you don't mind I just answer a few
of them (at a time) :-) By the way, my opinions are my own, I'm not an
official "Master of Swarm" or anything. Blame me if I'm wrong, not
Swarm!

A)1) In Swarm, objects usually belong to someone, i.e. the ObserverSwarm
belongs to main, the ModelSwarm belongs to ObserverSwarm, and swarms
(Agents etc) in the model belong to ModelSwarm (and swarm N in swarm N-1
belong to swarm N-1). It is the responsibility of the "owner-swarm" to
drop sub-swarms when needed. 
Say the ModelSwarm has a list of agents, agentList. An agent A dies and
needs to be removed. Agent A is saved in a "deadAgents" list until it is
safe to remove it from agentList. The ModelSwarm has an activity to
check deadAgents in each timestep. This activity (call it dropDead)
removes agent A from deadAgents and agentList and drops it.
You can find an example of this in the Swarm SugarScape, where agents
die and are removed from the model by a "reaper". You can get the code
at:

ftp://ftp.santafe.edu/pub/swarm/users-contrib/anarchy/sss-1.4.1.tar.gz

Here, the dropDead activity is called "reapAgents" and is found in
ModelSwarm.m

A)2) If you allow owner-swarms to drop sub-swarms, I don't think you
should have any trouble with parallel access.

A)3) A protocol is like a promise the programmer makes when he writes a
class, like your Cluster class:

@interface <List> Cluster: SomeClass
{
  ...
}
...
@end;

This just means "the interface of Cluster class supports the List
protocol" or said in a different way "Cluster can be used anywhere a
List is expected". In other words, it is a type declaration, that you
only need if you want to write compile-time type-correct code. With
Objective C, you don't have to make the effort to tell the compiler you
know what you are doing, but you can, with protocols.

B)1) I don't know what you mean by a category. An object of class
Cluster IS_A Cluster and IS_A SomeClass and is TYPE_OF List. If that's
not what you want, you can make a superclass of all you objects
(MySwarm) that responds to the message [mySwarm getCategory] in some
way. Am I off the mark here?

B)2) In stead of typedefs, I'd use interface declarations, such as
Cluster in the above example. I'm not sure what you're trying to do with
id <int>    x;
"int" is not a protocol, it's a basic type. If you think x should be an
integer, just use
int     x;
if you think x should be an object (of an unspecified type) just use
id      x;
Protocol declarations are not really needed. They are really just there
for compile-time type checking.

C) About gdb - I have no idea! I can't get the darn thing to work for
me. :-( I can't get the swarm apps to compile with the -g switch that
enables debugging information...


Hope this helps!

Eric Werk
University of Aarhus, Denmark
http://www.daimi.au.dk/~werk/

                  ==================================
   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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]