swarm-support
[Top][All Lists]
Advanced

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

Re: Lists in Swarm


From: Roger Burkhart
Subject: Re: Lists in Swarm
Date: Sat, 20 Jan 96 22:40:36 MST

> The object aGroup simply adds an object the list (which it contains) when 
> sent the message addOne.  On receiving the  message moveAll, aGroup will 
> send a message to each object in the list making it move.  Although I 
> could not get this to work using lists, it does work when I implement it 
> using an array I developed based on the Grid2D class in Mousetrap. 
> 
> Is this due to insufficient knowledge of Swarm classes or should it be OK?

It should be OK, at least as far as the ActionGroup sending the initial
moveAll message to your object aGroup.  After that it's all just C and
Objective C calls to do whatever you want.  If it works with your own
class but not when using List it suggests the problem might be in the
use of List.  Assuming valid contents of a list, here's a canonical
enumeration loop which could be used to move member objects.  If this
is close to what you're doing, your problem could also be that the
members of the list aren't what you expect them to be.

- (void) moveAll
{
  index = [groupList begin: scratchZone];
  while ( (member = [index next]) ) [member move];
  [index dropFrom: scratchZone];
}

As always, the best thing whenever you get crashes is to go directly
into gdb and look at the stack trace at the point of crash, to see
where the fault occurred and check for expected argument values, etc.
For my own work I don't try to develop objects without heavy interactive
use of a debugger, almost totally instead of print statements, to stop
and check things leading up to a fault.  Some of the tools we'll be
developing for Swarm include functions you'll be able to call directly
from the debugger to do useful things as the program runs.  We've got
some simple print things now, including an ability to print all members
of a collection with the "forEach" form of xprint, e.g.:

   call xfprint(aList)

It's good to think about an interactive debugger as the principal
development environment likely to be required for Swarm models.  I use
both gdb and Centerline Software's CodeCenter which I like for the
visual source window.  CodeCenter works fine on gcc-generated Objective C
code when running under their -pdm process debugging mode (which is
nothing but a front-end to gdb anyway).

One more debugging note: the standard gcc runtime library for Objective
C just ignores message sends to a nil object, even though in Swarm
libraries this is always basically a fatal error that often leads
quickly to segmentation or other fault.  This happens often enough
learning to use collections.  Nelson's section "debugging tips" gives a
couple way of intercepting these.  I always try to run a patched
version of libobjc.a with an immediate abort on a nil receiver.

Didn`t mean to get into a digression on debugging, but it's all I can
suggest for now, and hints on debugging could help others too.
Nelson's debugging tips in the swarmdocs give other useful info;
be sure to follow the link to "some workarounds" which explains
object inspection and message name mangling you'll need to understand
under a debugger.

-Roger


reply via email to

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