Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
$\begingroup$Make a class that represents the variable (as say with Java's Integer class), with private array that keeps track of all assignments/time stamp/counters, etc.. all hidden inside the class, Supply a set[] and get[] methods to the clients of your variable to use on the variable once it is instantiated. Making such Class in M is very easy. Make a Module, and inside the Module create the local variables and private methods. see mathematica.stackexchange.com/questions/586/… for one example.$\endgroup$
Trace[expr,i=_]
$\endgroup$