From: Ryan Davis Date: 2007-11-27T10:13:57+09:00 Subject: Re: C-Core-Questions On Nov 26, 2007, at 02:22 , wrote: > class X > $globvar = "hey" <- setting/instanciation of a global variable > def hello > hi = "hi" <- setting/instancition of a local variable > end > end AFAIK, there is NO hook available for notification of setting gvars. There is NO hook available for notification of setting local variables... Your code above looks like: > s(:class, > :X, > nil, > s(:scope, > s(:block, > s(:gasgn, :$globvar, s(:str, "hey")), > s(:defn, > :hello, > s(:scope, s(:block, s(:args), s(:lasgn, :hi, s(:str, "hi")))))))) to the parser. All of that code is executed in eval.c and if you look at rb_eval you'll notice that NODE_LASGN very cleanly just sets the value in the lvar table: case NODE_LASGN: if (ruby_scope->local_vars == 0) rb_bug("unexpected local variable assignment"); result = rb_eval(self, node->nd_value); ruby_scope->local_vars[node->nd_cnt] = result; break; I will say this one additional thing... USUALLY when I have people asking about "the name of the variable" or hooks on assignment etc, it is a hint of a bad design smell... What they're generally asking is a side effect of something that can be much more gracefully handled with a different design.