swarm-support
[Top][All Lists]
Advanced

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

Re:


From: Paul E. Johnson
Subject: Re:
Date: Tue, 04 Jan 2000 09:11:25 -0600

There are some words about this in the SwarmOnlineFaq:

http://lark.cc.ukans.edu/~pauljohn/SwarmFaq/SwarmOnlineFaq.html#6.6

I could have sworn we had that problem treated in the always-in-progress
user guide. I thought it was in chapter 8, but now I can't see it.

http://lark.cc.ukans.edu/~pauljohn/Swarm/Beta/SwarmUserGuide
there are userbook.ps and userbook.html in there.

I thought for sure I had written about it in the part on scheduling and
that M thing.  Dang.  I see in section 14.4 we have a treatment of
integer wrappers for use as keys in Maps, and I bet that is what I'm
remembering.

I think the short answer to your question is that, although it may work
on some systems, you should not be doing that casting of the int as an
id because an int and an id are not the same sizes on all platforms. 
Marcus explained another reason to me one time, but I can't remember
what it is.  You should avoid that even though lots of old swarm code
does it and even some things in the user guide and swarm docs do it.  

Perhaps I'm overstating the case, but I think this is was the majority
conclusion the last time this came up in this list. It is best to
rethink your model's design and find a way to avoid passing an int as an
argument to the selector.  One option is just to create a method
"getFirstOpinion" that does what you want below.  If you have many
opinions you need to get, I'm sure Marcus Daniels has posted code here
that uses integer wrapper objects to pass through this information.  It
is important to do this because swarm methods like createActionForEach
that take a selector argument assume that the variables passed with the
selector are type id, the default type in Objective C. They are done
that way because otherwise the swarm library would proliferate with
methods designed to accept ints, doubles, floats, pointers, arrays,
etc.  

If you look here:
http://lark.cc.ukans.edu/~pauljohn/SwarmFaq/WorkingExampleCode/objc/MapIntegerIndex.txt
You see how he has a class Integer and  macro INTEGER() that creates
objects that hold the value passed in parentheses.  

If you really don't want to change your approach, I wish you would tell
us what the problem is you have with M() before we try to figure out
what's wrong with your usage of @selector.  

pj



BEN SAID Lamjed thesard CNET/DTL/LAN wrote:
> 
> Hi,
>  I have a probblem when using the M( ) macro in the createAverageSequence:
> (const char *)aName withFeedFrom: aCollection andSelector: (SEL)aSel method
> . My getOpinion:(int)i method returns an integer opinions[i] stored in the
> array opinions[]
> 
> This is my code:
> [graphOpinions createAverageSequence: " Opinions "
>                          withFeedFrom: [consumerModelSwarm getAgentList]
>                           andSelector: M(getOpinion:):(id)0 ];
> 
> I just tried to replace it by the folowing andSelector:
> @selctor(getOpinion:) with:0 ] or to add brackets
> but no way the compiler consider
> createAverageSequence:withFeedFrom:andSelector:: or
> createAverageSequence:withFeedFrom:andSelector:with as non implemnted
> methods , which is true !.
> 
> Any way to do it?
> THANKS
> 
> ******************************************
> Lamjed BEN SAID
> Thésard CNET
> Adr : France Télécom CNET DTL/DLI
> 2, avenue Pierre Marzin - 22307 Lannion Cedex -France
> Tel :  (33) (2) 96 05 14 30
> Fax :  (33) (2) 96 05 19 56
> Mail :  mailto:address@hidden
> ******************************************
> 
>                   ==================================
>    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.

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