From: "Ball, Donald A Jr (Library)" Date: 2007-05-19T00:06:56+09:00 Subject: Re: questions about reimplementing core classes > > 3. I had vaguely thought that the default freeze > implementation would > > freeze all instance variables, but it does not. Is this a > good way to > > implement freeze? (with the exception of the incorrect > return value?) > No that is not a good way I am afraid. Please note that one > cannot freeze instant variables - I have a reason to be picky > here, I believe > - but the objects they are referring to. > Do you see the implications of a "deep" freeze now? The whole > program will probably get cold feet ;) as objects just > referenced in our object would be frozen. Heh heh heh, that hadn't yet occurred to me, but your point's well taken. > However what you are doing is clever of course, you freeze > the objects you have created as containers for other objects > without freezing the objects the container references, do you > see how bad it would be again if your SortedHash froze all > contained objects? Of course. But what I'm doing is fine, at least as far as it goes, yes, since I have relatively simple internal data structures? If it were more complex, it would be better to explicitly check frozen? in each of the methods which could modify state? (which means i really ought to put in a super call in my freeze method...) - donald