Tom Sawyer wrote:
> i have a little experience tracking object states: i wrote some code to do 
> this for GUtopIa. your difficulty is the BEFORE modification. what i did when 
> tracking object state was powerful but far from elegant: i simply ran through 
> every method of an object and aliased it such that a hook/trap method was 
> called along with the original method. in my case i beleive i inserted the 
> call after the fact to see if anything changed. in your case you will want to 
> do it before the fact to "lock" the object (btw, how do you do that?)

Hi Tom,

Thanks for the input.  AspectR provides functionality for wrapping 
methods as you've done, so I'm using AspectR to do the wrapping.  As for 
the locking, I'm basically just locking the local object with a mutex 
and calling the GOODS "cmd_lock" command.  This, of course, is 
GOODS-specific.  I don't have a general solution at this point.

At this point, I'm starting to wonder whether it's even possible to trap 
modifications to an object.  I know that I could patch the interpreter 
and modify rb_ivar_set, but I don't want users to have to rely on a 
patched interpreter.

Is there another way to accomplish what I want, either through C or Ruby 
proper?

matz:  Is this kind of need common enough to warrant an RCR?

-- 
Jason Voegele
"There is an essential core at the center of each man and woman that
remains unaltered no matter how life's externals may be transformed
or recombined. But it's smaller than we think."
     -- Gene Wolfe, The Book of the Long Sun