-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 26 August 2002 05:11, David Garamond wrote: > Yukihiro Matsumoto wrote: > > |2. is there a beast called a 'global constant'? i tried defining $Foo > > |and ruby allows me to rebind $Foo later. > > > > No. $Foo is a plain global variable. > > thanks matz. > > i want to protect some global variables without having to resort to > setting $SAFE to 4. can we use some proxying mechanism, or override an > object method to trap assignment/binding? freeze() only protect the > object value, and does not prevent rebinding. Kernel.trace_var? chandler@greyhound:~$ irb irb(main):001:0> trace_var :$global, proc{|v| $global = 'foo'} nil irb(main):002:0> $global = 'pet' "pet" irb(main):003:0> p $global "foo" nil Perhaps make Globals class and make all the variables as instance or class variables with only attr_reader set or only getter methods? -michael ++++++++++++++++++++++++++++++++++++++++++ Michael C. Libby <x / ichimunki.com> public key: http://www.ichimunki.com/public_key.txt web site: http://www.ichimunki.com ++++++++++++++++++++++++++++++++++++++++++ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9agtC4ClW9KMwqnMRArkVAJoCKR1mX5CyFGis0kPBGu/qA+1LLQCeM7Oh vF4BFJUoNNWYukGy8IjunYk= =MdzY -----END PGP SIGNATURE-----