From: ara.t.howard@... Date: 2006-07-16T01:37:34+09:00 Subject: Re: Preferred monkeypatching technique On Sat, 15 Jul 2006, Daniel Martin wrote: > Eric Hodel writes: > >> You don't need a mutex. >> >> class Symbol >> @gensym_count = 0 >> def self.gensym >> ("__gensym__%X" % @gensym_count += 1).intern >> end >> end > > Okay, but now if two different files include this exact code, you're > re-generating the same symbols. This is why I used ||=, making your > code: > > class Symbol > @gensym_count ||= 0 > def Symbol.gensym > ("__gensym__%X" % @gensym_count += 1).intern > end > end > > At the very least, two people using the same exact code to define > gensym shouldn't collide with each other. if two different files have this exact same code inlined the programmer should be shot. if two different files require a third that contains this code then there will be no problem. 2 cts. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama