swarm-support
[Top][All Lists]
Advanced

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

Re: lispAppArchiver ref?


From: Paul E Johnson
Subject: Re: lispAppArchiver ref?
Date: Mon, 04 Dec 2000 09:26:56 -0600

Alex wrote up a thing on that in the user guide, but I don't guess  it
shows much more than Heatbugs.  As recently as 6 months ago, Marcus was
doing some pretty serious revision/enhancement in there.  As I recall,
bool should be set #t and #f.  I'm sorry I can't get fast enough
internet access right now to check the Swarm archives, but if you look
back in Spring, 2000, you should find a note from me with a content like
"what the hell is lispAppArchiver all about" because I was finding a
run-time crash because variables were set wrongly in the scm file and
swarm did not checking.  In there, he had a link to a place where
variable declarations for Lisp were clearly explained, and I should find
it, when I have faster net access than I do now. 

Aside from that, I have a few notes about it. Jason Alexander wrote me a
test program.

------------------------------

Over the weekend I was doing some Swarm coding and had the opportunity
(need) to consult the Swarm User's Guide.  Very nice exposition,
clear, and helpful.

When I was reading the chapter on serialization, though, it occured to
me that you might want to include a note on the following trick for
figuring out the correct input syntax for the LispArchiver.  Suppose
that you have a class of the following form

@interface MyObj: SwarmObject
{
  const char *some_name;
  double foo;
  float bar;
  char baz;
  BOOL two_d_array[5][5];
}
@end

and you want to be able to initialize it when the model starts using
the LispArchiver.  What's the correct syntax for the string?  The
char?  A 2-d array of BOOLs?

The easiest way to figure it out is to create a simple little Swarm
program which (1) creates an instance of the class MyObj, and (2)
writes it to a file.  Then you can read the file and see what the
correct syntax is.

Here's one such program:

// You might need additional #import lines here...
#import <simtools.h>

// Define the class we want to serialize
@interface MyObj: SwarmObject
{
  const char *some_name;
  double foo;
  float bar;
  char baz;
  BOOL two_d_array[5][5];
}
+ create: aZone;
@end

@implementation MyObj
+ create: aZone
{
  int i,j;
  MyObj *obj = [super create: aZone];

  // Set some initial values
  obj->some_name = "The Talented Mr. Ripley";
  obj->foo = 1.0;
  obj->bar = 2.0;
  obj->baz = 'a';
  obj->for (i=0; i<5; i++)
    for (j=0; j<5; j++)
      obj->array[i][j] = (i+j<5) ? YES: NO;

  return obj;
}
@end

// And now the program...
int main (int argc, const char ** argv)
{
  id obj;
  id foo;

  // Swarm initialization: all Swarm apps must call this first.
  initSwarmArguments (argc, argv, [NashArguments class]);

  MyObj* obj = [MyObj create: globalZone];

  foo = [[[LispArchiver createBegin: globalZone]
                setPath: "output-file-name"]
              createEnd];
  [foo putShallow: "aKey" object: obj];

  // The next line might need to be changed to [foo sync] in
  // newer versions of Swarm
  [foo save];
  return 0;
}


It's pretty clear how this program can be modified to figure out the
syntax for any object that doesn't include other objects.  If you
think this would be a good topic to include in the User's Guide, I can
put together (I think) an example which shows how to use Swarm's
"Deep" serialization, which serializes objects that contain other
objects.

Cheers,

Jason
------------------------------------------------------

I thought that was cool.  Alex Lancaster (in a note I cannot find)
pointed out to me in the Swarm test directory, there already was a
similar kind of test program. At the time, I recall I confirmed it, but
did not have time/inclination to write up any more thorough
documentation on it.  I felt that way partly because the lispAppArchiver
is a little bit "shaky",(partly because of those runtime crashes I
mentioned) in the sense that it was developed as a test for the HDF5
archiver and it was pretty clear from a conversation we had at Swarmfest
that one ought rather use the hdf5 archiver.  But, as I was working on
the artificial stock market model, I went ahead and used lispAppArchiver
because it seemed easier to code and explain to people.  If you check
out the CVS for the ASM project, you will see those things. Last summer
I did not get far enough to make it worth (in my opinion) a numbered
release, but you can see the cvs.


"Marcus G. Daniels" wrote:
> 
> >>>>> "KG" == Ken Gosier <address@hidden> writes:
> 
> KG> Can someone point me to a ref on the details of how
> KG> lispAppArchiver works?


-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

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