swarm-support
[Top][All Lists]
Advanced

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

Re: Is "static" meaningful in Objective-C methods?


From: Paul E Johnson
Subject: Re: Is "static" meaningful in Objective-C methods?
Date: Wed, 01 Nov 2000 17:56:04 -0600

"Marcus G. Daniels" wrote:
> 
> >>>>> "PJ" == Paul E Johnson <address@hidden> writes:
> PJ> Using this in Swarm would let me get rid of a bunch of IVARS that hold
> PJ> values of seldom-used methods, so I could clean up some code.
> 
> It seems fishy that an instance variable would ever be changed to static
> state, since one is local to an object and the other modifies the
> behavior of any object that calls the method.

OK, I don't want instances to share the static variable, so I won't do
it. 

So you don't think I'm totally insane, here is why I wanted do do this.
I was looking at using simulated annealing to optimize something (the
Gnu Scientific Library code makes it quite clear how this can be done,
incidentally).  In the method to do the simulated annealing, it uses
some variables that are adjusted each time the method is called.  For
example, the T variable ("Temperature")  shrinks T just a bit, say
T=T/1.1.  T is used in no other methods, so it is not needed as an IVAR,
except that each time the method is called, of course, it has to know
its previous value.

I'm reading a C book that recommends using static locals in place of
global variables where possible. Too bad Obj-C methods don't allow it.

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