swarm-support
[Top][All Lists]
Advanced

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

Re: Eleven more Heatbugs questions...


From: Ken Cline
Subject: Re: Eleven more Heatbugs questions...
Date: Tue, 29 Jul 1997 16:09:37 -0400 (EDT)

On Tue, 29 Jul 1997 address@hidden wrote:

> In heatbug.h:
> 
> 6) What does "Grid2d * world;" do?  Does it create a object "world"? 
> What is the "*" do?  Is it used to declare objects?

This declares a variable called "world" which is of type
"Grid2d *".  "*" is C syntax for pointer.  So "Grid2d *" is
a pointer to a "Grid2d" class.

That's as far as I'm going down the "what's a pointer?"
path...  What I mean is the more you try explain what
pointers are and how you use them in C, etc. the confused
everyone gets... Look in any good C reference for more about
pointers.  (Warning: the more comfortable you are with the
pointer, the less you understand them! [grin])

> 7) What "type" is Color?  A object or a varible?

      % pwd
      /opt/proj/swarm/SWARMHOME/src
      % grep Color */*.h
          ...
      tkobjc/XColormap.h:typedef unsigned char Color;
          ...

So, Color is unsigned char defined type.


> In HeatbugModelSwarm.m:
> 
> 8) Is "obj" a swarm or just an object?  And when you "obj->foo=1;" does
> that set foo in the "obj" to 1...probably dumb question.  Does it matter
> what foo is as far as public, private, or protected?

I suspect that "obj" is a pointer to an instance of some
class (ie a pointer to an object).

"->" is a C operator and "obj->foo=1" does, just as you say,
assigns to the member "foo" of object "obj" the value 1.

Public, private, or protected matters if the statement is in
some class other than "obj"'s class. Confused?

What I mean is, in HeatbugModelSwarm.m,
   +createBegin: (id) aZone {
      HeatbugModelSwarm * obj;
         ...
      obj = [super createBegin: aZone];
         ...

      obj->numBugs = 100;
         ...
   }

Here obj is a pointer to an instance of HeatbugModelSwarm.
Public, private or protected doesn't matter because we're in
the HeatbugModelSwarm class.

However, in HeatbugObserverSwarm.m, if we had:
      HeatbugModelSwarm * obj;
         ...
      obj = [HeatbugModelSwarm create: aZone];
         ...

      obj->numBugs = 100;
         ...

Now public, private or protected matter since we're trying
to access a variable of HeatbugModelSwarm from another
class.

Sorry, I'm not explaining that very well.  See an
Objective-C or a C++ book for more about limiting access.

BTW, Objective-C doesn't like "static typing" (that is,
"obj->foo") outside of a factory method.


> 9) Is "message:" a method or a label? 

Label/Keyword.


> 10) In this line:
> "[modelSchedule at: 0 createAction: modelActions];"
> What is modelScedule?  Is the message/method "at:createAction:"?

modelSchedule is an instance of the Schedule class.  See the
swarm docs for explanation of schedules...

http://www.santafe.edu/projects/swarm/swarmdocs/index.html#core


> In HeatbugObserverSwarm.m:
> 
> 11) In this line:
> "[worldRaster setButton: ButtonRight Client: heatbugDisplay Message:
> M(makeProbeAtX:Y:)];"
> What are the types? objects? methods?  Why is Message: start with a
> (cap) "M"?  Everyother time I see message: its lowercase?

"Message" or "message" ... this goes back to naming
conventions.  Whoever wrote the setButton method chose to
use a capital "M" so that's the way its declared.  When you
call the method, however, you don't have the choice.  That
is, if you had

   [worldRaster setButton: ButtonRight 
                   Client: heatbugDisplay 
                  message: M(makeProbeAtX:Y:)];

the compiler would complain that this method was not defined
in the ZoomRaster class.  (Unless, a superclass of
ZoomRaster has this method, I doubt that though.)



_________________________________________________________
Ken Cline                             address@hidden
SAIC                                 VOICE (410) 571-0413
Annapolis, MD                          FAX (301) 261-8427


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