From: Eric Hodel Date: 2006-07-15T02:26:34+09:00 Subject: Re: Preferred monkeypatching technique On Jul 14, 2006, at 10:02 AM, Logan Capaldo wrote: > Neat idea, gensym in Ruby. I would suggest making it thread-safe > though: > > % cat gensym.rb > require 'mutex' > class Symbol > GensymLock = Mutex.new > def self.gensym > GensymLock.synchronize { > @@gensym_count ||= 0 > @@gensym_count += 1 > ("__gensym__%X" % @@gensym_count).intern > } > end > end You don't need a mutex. class Symbol @gensym_count = 0 def self.gensym ("__gensym__%X" % @gensym_count += 1).intern end end -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com