From: ts Date: 2002-08-26T19:26:07+09:00 Subject: Re: warning modifying constant & 'global constant' >>>>> "D" == David Garamond writes: D> i want to protect some global variables without having to resort to D> setting $SAFE to 4. can we use some proxying mechanism, or override an D> object method to trap assignment/binding? freeze() only protect the D> object value, and does not prevent rebinding. ruby has internally read only variables, for example : pigeon% ruby -e '$LOAD_PATH = "aaa"' -e:1: can't set variable $LOAD_PATH (NameError) pigeon% but pigeon% ruby -e '$LOAD_PATH << "aaa"' pigeon% well, pigeon% ruby -e '$LOAD_PATH.freeze; $LOAD_PATH << "aaa"' -e:1:in `<<': can't modify frozen array (TypeError) from -e:1 pigeon% but pigeon% ruby -e '$LOAD_PATH.freeze; $LOAD_PATH[0] << "aaa"' pigeon% etc Guy Decoux