swarm-support
[Top][All Lists]
Advanced

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

Re: question about copying agents


From: Paul E. Johnson
Subject: Re: question about copying agents
Date: Tue, 13 Apr 1999 21:59:34 -0500

"Marcus G. Daniels" wrote:
> 
> >>>>> "PJ" == Paul E Johnson <address@hidden> writes:
> 
> PJ> What does "shallow" mean, as opposed to "deep"?
> 
> A shallow copy is one where references remain references.  If there is an
> object referenced in the object that is copied, that referenced will
> not be copied, merely the reference will be copied.  

I don't have any really serious reason for asking, but I'm still
curious.  

Your answer translated my ignorance from "shallow/deep" to
"reference/unreferenced".  In looking at an object, I lack a way to
separate the referenced from the unferenced.  Is the key question
whether the createBegin/createEnd sequence is called inside an object's
zone or that pair is executed somewhere else and then a pointer to the
object is passed over?

Maybe you could just consider an example such as heatbugs ModelSwarm. It
creates all those bugs and then sets each one in a list.   If you remove
one bug and apply copyIVars to it, which IVars would be copied?  I think
it is safe to say that any non-pointer kind of variable will be copied,
so all floats, ints, BOOL. Probably also C arrays of those types.

But objects created in ModelSwarm and set for each individual heatbug
are not copied. Each heatbug has a variables heat and world. copyIVars
would not copy the world, since heatbug does not "own" it.  But a copy
of a heatbug would have a copy of the pointer to the heat and world
objects?  
 
It seems to me this could have important design implications. Suppose
you want to have heatbugs with objects inside them, say to reflect their
experience and records.  If you want to be able to copy a heatbug of
that kind, you would not want to create the record-object in ModelSwarm
and then pass it in with a "set" method.  Rather, that record-object
should be created by methods in Heatbug.m, so it would be copied as well
when the heatbug is copied.

By how many miles am I missing the barn on this one?

-- 
Paul E. Johnson                         email: address@hidden
Dept. of Political Science              http://lark.cc.ukans.edu/~pauljohn
University of Kansas                    Office: (785) 864-9086
Lawrence, Kansas 66045                  FAX: (785) 864-5700

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