swarm-support
[Top][All Lists]
Advanced

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

Re: Macro Usage---further problem


From: Paul E. Johnson
Subject: Re: Macro Usage---further problem
Date: Tue, 27 Apr 1999 09:26:22 -0500

xueyue wrote:
> 
> Marcus G. Daniels wrote:
> >
> > >>>>> "XH" == xueyue  <address@hidden> writes:
> >
> > XH> [growthSchedule at: time+growthInterval
> > XH>      createActionTo: foodSpace
> > XH>               message: M(putValue:atX:Y:):1:x:y];
> >
> > XH> egcs -c -Wno-import -Wno-protocol -g -O2 -fno-inline -D_GNU_SOURCE
> > XH> -I/usr/include/swarm ModelSwarm.m
> > XH> ModelSwarm.m: In function `_i_ModelSwarm__scheduleGrowthAtX_Y_':
> > XH> ModelSwarm.m:191: warning: passing arg 4 of
> > XH> `at:createActionTo:message::::' makes pointer from integer without a 
> > cast
> > XH> ModelSwarm.m:191: warning: passing arg 5 of
> > XH> `at:createActionTo:message::::' makes pointer from integer without a 
> > cast
> > XH> ModelSwarm.m:191: warning: passing arg 6 of
> > XH> `at:createActionTo:message::::' makes pointer from integer without a 
> > cast
> >
> > To avoid warnings, use "(id) 1 : (id) x : (id) y" instead of "1:x:y".
> > The reason this works is that integers and pointers are the same
> > size on most machines.
> 
> Alright, it will work in this way. However, I am afraid there
> is further problem: what if the arguments data types are not
> integer? For example, for a method:
> -stepFloat:(float) f Double: (double) d;
> can we use
> M(stepFloat:Double:):0.3:0.5 ....?
> It seems the answer to this question is not, from my
> experience. If my answer is true, then this Macro selector
> has clearly a setback.
> Xueyue
Oh, man, did I fight with that one! That problem hit me at the very
beginning of my Swarm-time and it has significantly affected my work.

Unless something has changed, you cannot pass a float through in this
way.  Instead, you need to create some kind of "wrapper class" that can
set and get the values of your float.  In my case, there is a class
called "Point" and inside point there is an array of floats. Point
answers to a method "getCoordinate:", which returns the right value for
that coordinate. Instead of trying to pass naked floats to
stepFloat:Double:, you can rewrite your method as just "stepFloat:" and
then have stepFloat receive an id of type Point and then inside
stepFloat the array items can be retrieved by the getCoordinate: method.

Benedikt and Glen helped me very much when I was trying to understand
this way back when and as I recall some of the items in the faq, the
ones with titles like "more whining about M():", touch on these issues.

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