swarm-support
[Top][All Lists]
Advanced

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

Re: create: vs createBegin: ?


From: Roger M. Burkhart
Subject: Re: create: vs createBegin: ?
Date: Mon, 27 May 1996 18:50:23 -0500

I'm freshly returned after ALife V, so I'll respond to your question:

> I am confused about when to use create vs createBegin/createEnd.
> For example, in heatbugs (this is 960513) for the model object
> there is:
> 
> heatbugModelSwarm = [HeatbugModelSwarm create: modelZone];
> 
> Now in the HeatbugModelSwarm.m/.h files there is
> a +createBegin and a -createEnd.  Why aren't they used?
> Perhaps -create does them both in one fell swoop?
> (maybe I missed this in the doc...)

For any object type that implements the standard create message protocols,
such as HeatbugModelSwarm in your example, the following are completely
equivalent:

  heatbugModelSwarm = [HeatbugModelSwarm create: modelZone];

vs.

  heatbugModelSwarm = [HeatbugModelSwarm createBegin: modelZone];
  heatbugModelSwarm = [heatbugModelSwarm createEnd];

If you have no special messages to send between createBegin: and
createEnd, it's simpler to just say create:, so we provide that as a
convenience.  For speed, some classes may have a separate method for
create:, but otherwise one is inherited that calls createBegin: followed
by createEnd just like the above.

There's new documentation about this in the defobj library reference docs
(under Create), but the documentation for SwarmObject (which is the path
through which most objects see any defobj messages) seems to mention only
createBegin: and createEnd, and not the simple create:.

Roger


reply via email to

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