swarm-support
[Top][All Lists]
Advanced

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

Re: Yes, even more heatbug/Swarm programming style questions...


From: Theodore C. Belding
Subject: Re: Yes, even more heatbug/Swarm programming style questions...
Date: Mon, 28 Jul 1997 15:06:53 -0400 (EDT)


On Mon, 28 Jul 1997 address@hidden wrote:

> All,
> This is probably a bit of a "newbie" question, but (while going through
> the heatbugs code) what is "M" in this statement:
> 
> [[heatbugModelSwarm getHeatbugList] forEach: M(setBugColor:) : (void *)
> 64];
> 
> I would assume that it is a array of all the bugs in a given run, but I
> don't want to assume anything since I have to teach this to others on
> Wednesday...[frown]  and is forEach a method or a label?  and how should
> I interpete the rest of it?  Is "(void *) 64" the creation of the actual
> "M" array? 

This gets the list of heatbugs from the model swarm, then uses the 
"forEach" method (without an argument name, which is confusing if you 
don't know what's going on and is probably not very good style because 
of that, though we all do it) to set each bug's color (using the heatbugs' 
setBugColor method) to the value 64.  M() is a macro that is used in Swarm 
to pass the name of a method to some other object (here, the list). 
"(void *) 64" casts the value 64 to type "pointer to void" or generic 
pointer (technically I think it should be type id but it doesn't matter 
since both types have the same length).  Hopefully someone can correct me
if I'm wrong since I haven't done any Swarm hacking in a year or so.

> "M" array? And later in buildActions it references M again, is this the
> same M?  And in buildActions under many messages like this one:
> 
> [displyActions createActionTo: unhappyGraph message: M(step)];
> Is this the same M?  If not where was this M initialized/declared?  And
> is message a label or a method?

Again, M() is a macro that passes the name of the step method to the 
displayAction object's createActionTo method.

[...]

> And what about Methods like: SetX: x Y: y  Is the method SetX: and Y:
> the same method or two different ones?  Or is Y: a label?  If Y is a
> label, isn't that unfair to Y, to make it a label to SetX:.....[grin]

It's one method. The way you write an Objective C method name for SetX: x 
Y: y (I think) is "SetX:Y:", where "SetX" is the method name (with the 
name of the first argument omitted) and "Y" is the name (label) of the 
second argument.  More explicit but less concise would be 
[anObject Set X: x Y: y], which is a different method from the one above
(Set, instead of SetX).

Hope that helps.
-Ted

--
Ted Belding                               address@hidden 
University of Michigan Program for the Study of Complex Systems
http://www-personal.engin.umich.edu/~streak/



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