From: Ralph Shnelvar Date: 2009-11-06T01:10:41+09:00 Subject: Re: Freeze not freezing Matz, I deeply appreciate your answer. But I will repeat part of the question: Is there a way to detect ... in the general case ... that the reference to an object has changed? In a more C-like environment, a debugger is able to detect (via hardware) that a location in memory has changed. Is something similar available in Ruby? Where is the Ruby debugger (watch, etc.) documented? Ralph Thursday, November 5, 2009, 7:14:11 AM, you wrote: YM> Hi, YM> In message "Re: Freeze not freezing" YM> on Thu, 5 Nov 2009 23:05:28 +0900, Ralph Shnelvar writes: YM> |a) Is my reasoning correct? YM> #freeze protect an object from modification. The reference is not the YM> target of freezing. YM> |b) Is there a way to do what I want? That is, freeze f or c[0] so that YM> |I get some sort of message/error/exception? YM> You can protect an array (or object) as a whole, since it is an YM> object, so that YM> c=[0,1] YM> c.freeze YM> c[0]=2 # => can't modify frozen array (RuntimeError) YM> but you cannot freeze any variables. YM> |c) Do my examples violate POLS? YM> No. Unlike C++, variables and references are not object in any sense YM> in Ruby. From my viewpoint, C++ violates POLS. ;-) YM> matz. -- Best regards, Ralph mailto:ralphs@dos32.com