From: Joel VanderWerf Date: 2008-07-22T04:54:22+09:00 Subject: Re: Thread-local global variables? class Module def thattr name module_eval <<-code def #{ name }() Thread.current[#{ name.to_s.inspect }] end def #{ name }=(v) Thread.current[#{ name.to_s.inspect }] = v end code end end class Foo thattr :x end foo = Foo.new bar = Foo.new foo.x = 1 p bar.x # ==> 1 This looks a little weird to me. But it does have the advantage that the method is defined only in the scope where you use it. (In a way, that's a disadvantage, too, since it obscures the fact that "x" really does have a bigger scope, namely the Thread.current#[] method.) -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407