Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Suggestions for Maintaining "Object" State?

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

Hi Carey,

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

assume 2 objects a and 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?