swarm-support
[Top][All Lists]
Advanced

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

Re: heatbug copy method and happyspace concept...


From: Roger M. Burkhart
Subject: Re: heatbug copy method and happyspace concept...
Date: Thu, 7 Aug 1997 18:49:25 -0500

Brad Leydorf writes:

> I did look into the archives and found the discussion thread "copying
> protocols and ravioli", and saw the code snipet:
> 
> - copy: aZone
> {
> return [aZone copyIVars: self];
> }
> 
> If I stick this in heatbug.m and call it in the -step method, or just
> put it in a "if statment like:
> if (unhappiness < 0.05) {
> return [aZone copyIVars: self];
> }
> 
> Would that work?  To make a functioning copy of a bug?  Am I making a
> copy of a "aZone", instead of a "bug"?  What does "copyIVars:" do? (I
> would assume copy instance variables), but it still doesnt seem clear to
> me...Would I need to point heatbug at any other "core" library to get
> these to work?

Yes, this would make a copy of the instance variables of an existing
heatbug and return a new heatbug.  You still need to arrange to add that
heatbug to a collection of all the heatbugs or include it some other
scheduled action for it to receive any scheduled update messages, but that
fragment of code is sufficient to make the copy of the heatbug itself. 

> I was under the impression that the zones were memory space where all
> the bugs lived, but, this implies (if Im grasping it right) that each
> bug has its own "zone"?

No, the meaning of any message is what's defined in its specification.
It's not necessarily defined by anything about the order of its arguments.

The zone is responsible for allocating all objects within it.  You do
have to make sure your "aZone" argument is set to the zone where you want
the bug created.  If you want to create the bug in the same zone as the
existing heatbug, you have to send the message to the zone where that
heatbug already lives when you call the copy: message:

  newHeatbug = [[existingHeatbug getZone] copy: existingHeatbug];

The copy: message gives the flexibility to create the new copy in any
zone you wish, but if you want it to live in the same zone as all the
rest you just ask for that.

--Roger


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