swarm-support
[Top][All Lists]
Advanced

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

Re: Event's Parameters


From: Paul E Johnson
Subject: Re: Event's Parameters
Date: Wed, 11 Jul 2001 11:43:13 -0500

Olivier Jauze wrote:
> 
> hi,
> 
> is it possible to pass parameters when I schedule an event.
> 
> For exemple, suppose I have an event call suppresion with a methode
> associate named suppression
> Can I declare this methode like this : public void suppression ( int i ) ?
> If it is possible, Can I schedule this event like this :
> modelSchedule.at$createActionTo$message ( time, entity, new Selector(
> entiteIn.getClass(), "suppression(2)", false));
> 
> Thanks in advance
I have to admit I do not understand very well the passing of arguments
in Java, and I wish I did.  I think recently Marcus has proposed a
simpler interface for creating actions and I bet he will jump in this
thread when he has a moment.  I thought I had a WorkingExampleCode usage
of a java program that passed arguments, but can't find it now.  (I'm
looking in
http://lark.cc.ukans.edu/~pauljohn/SwarmFaq/WorkingExampleCode/java).

Maybe I can tell you what I understand about objective C and you can
translate this in to Java.  In objective C, your createAction messages
can have up to three arguments, but all must be of type id.  That is,
they must be objects.  Since on some platforms integers are the same
size as pointers, you can cast an integer as an id and pass it through
that way.  Now, to a java user, this should seem quite intuitive,
because Java reflection works on the same principle.  If you need to
pass an integer argument x , you pass through Integer(x) and then the
receiver gets the value out.

I wrote this out in pretty much detail in the swarm User Guide, under a
heading What's that M() thing?  If you have an html version, look in
this file:
/swarm.user.user2.04-macro.sect1.html

It has a syntax like this:
 [modelSchedule2 at: 1 createActionTo: proposalSchedule message:
M(activateIn:): self];
Here I am passing self as an argument.  If I were passing more
arguments, it would have more colons.  as in
M(doThis:OrThat:OrOther:):x:y:z.  Inside the M() I have the full method
name, and after I have the object arguments.

I'm just now studying the Java reflection libraries and I'm trying to
formulate a simpler api for doing this kind of thing so I can teach my
students java.  I do not know if I will ever succeed, because making a
general purpose class that works within the general Swarm context is
most challenging to me.

Perhaps if you get a small working example which passes arguments using
the existing swarm libraries, you will forward it to me and I will put
it in the archive referred to above.
-- 
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]