From: Erik Veenstra Date: 2006-07-10T21:24:54+09:00 Subject: Re: instance_exec > Anyway, here the version I put in Facets. Please evaluate. > > # The implementation is thread-safe thanks to the > # Thread.current.object_id trick, but it doesn't work with > # immediate values (Fixnums and friends),... (You're version _does_ work with immediate versions.) Mmh... The Module version does work for immediate versions, too. That might be a good reason... ;] Mine doesn't... > # ...and most > # importantly it bombs when given a frozen object. > > Object.class_eval{ define_method(mname, &block) } This pollutes the global class Object. Not funny... ;] But, yes, it does work... The Module versions only pollutes the class Object with one, dedicated Module. That's not too bad. If we want to handle immediate values and we can't create singleton classes for them, we have to abuse something. Maybe, after all, the Module version isn't that bad... ;] gegroet, Erik V. - http://www.erikveen.dds.nl/