From: Tom Cloyd Date: 2009-01-23T09:51:20+09:00 Subject: Re: String doesnt auto dup on modification Robert Dober wrote: > On Wed, Jan 21, 2009 at 8:15 PM, RK Sentinel wrote: > >> I'm writing my first largeish app. One issue that gets me frequently is >> this: >> >> I define a string in one class. Some other class references it, and >> modifies it. I (somehow) expected that when another referer modifies the >> reference, ruby would automatically dup() the string. >> >> Anyway, through trial and error, I start dup()'ing strings myself. I am >> aware of freeze(). >> >> But would like to know how others handle this generally in large apps. >> >> - Do you keep freezing Strings you make in your classes to avoid >> accidental change >> >> - Do you habitually dup() your string ? >> > I try to, and I try to get rid of all references to the original > string as soon as possible. > This is because incremental GC works so well nowadays and allows for > some clean code. > Freezing a string seems like a good idea sometimes, but if that means > holding on to the object longer than needed this might not be such a > good idea after all. > > R. > Robert, for those of us who are considerably more clueless, what is "incremental GC"? Thanks, t. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist Bellingham, Washington, U.S.A: (360) 920-1226 << tc@tomcloyd.com >> (email) << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~