swarm-support
[Top][All Lists]
Advanced

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

Re: [Swarm-Support] Selectors


From: Paul Johnson
Subject: Re: [Swarm-Support] Selectors
Date: Wed, 09 Jul 2003 09:31:51 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225

This is a "wrapper" problem. The only valid type of variable in forEach: is an id or pointer. Some people cast integers as pointers to do this kind of thing, but floats are a no-go as far as I understand. I think in the User Guide's discussion of scheduling it talks about creating wrapper objects to pass variables to and fro. FOr example, you could create a class SwarmFloat, set a value in there, and pass it through the way you want.

But please just consider taking the simple, direct route: iterate over your list.

id <Index> index = [list begin: [self getZone]];
id anObj;
for (anObj = [index next]; [index getLoc]==Member; anObj = [index next])
{
        [anObj setPayoff: pay];
}

Marcello wrote:
Pardon me the frequency of my questions!

I have a method in a class Agent:

- setPayoff: (float) p {

payoff=p;

return self;
}

Now, in another class, I have a List of Agent called "group". I'd like
to pass through the list and set the payoff as follows:
float pay=10.1;
[group forEach: M(setPayoff:): pay ];

If I do that, I get
gcc: incompatible type for argument 4 of indirect function call

if I set
[group forEach: M(setPayoff:): (id) pay ];
id does not work either,

it only works if :
[group forEach: M(setPayoff:): (int) pay ];

but then pay is always zero.

Any help?
thanks
marcello


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



reply via email to

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