MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Suggestions for Maintaining "Object" State?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78342] Re: Suggestions for Maintaining "Object" State?
  • From: dh <dh at metrohm.ch>
  • Date: Thu, 28 Jun 2007 06:29:56 -0400 (EDT)
  • References: <f5vsk1$l46$1@smc.vnet.net>


Hi Carey,

you could try to put all the states into a function. E.g.:

assume 2 objects a and b:

a={1,2};

b={4,3,2,1};

states[a]=a;

states[b]=b;

states[x] will then return the state of x.

hope this helps, Daniel



Carey Sublette wrote:

> I am starting to develop a fairly complex simulation using Mathematica 6 and 

> am confronting a basic issue that I am unsure how best to resolve: "How to 

> preserve the state of an object?"

> 

> Physical objects represented in a simulation have internal state that is 

> preserved and affects how they respond to stimulus from the simulation 

> environment.

> 

> Possible ways of implementing this behavior includes creating modules 

> representing objects and:

> *  exporting state to the session (or other enclosing scope) as a list of 

> values, which either exists as a global variable or is passed in as a 

> parameter;

> * using UpValues or Tags to assign object state to symbols(?).

> 

> At the moment the objects in the simulation have a 1-to-1 relationship, 

> there is only one of each type, which simplifies the problem, though in the 

> future I may need to maintain state for multiple objects of the same type.

> 

> Does anyone have recommendations for how to do this, optimized either for 

> convenience or efficiency? 

> 

> 




  • Prev by Date: Re: comparing rewite rules
  • Next by Date: Re: Suggestions for Maintaining "Object" State?
  • Previous by thread: Suggestions for Maintaining "Object" State?
  • Next by thread: Re: Suggestions for Maintaining "Object" State?