Erik Veenstra wrote: > Okay, criticizing somebody's work without providing a > "solution", isn't nice at all... > > So, here's my version... > > gegroet, > Erik V. - http://www.erikveen.dds.nl/ > > PS: I'm still curious about the reason for using a module. I think the idea was to save frm creting a singleton class, but at the expense of a module I don't see why either. Anyway, here the version I put in Facets. Please evaluate. module Kernel # Like instace_eval but allows parameters to be passed. # # The implementation is thread-safe thanks to the # Thread.current.object_id trick, but it doesn't work with # immediate values (Fixnums and friends), and most # importantly it bombs when given a frozen object. def instance_exec(*args, &block) mname = "__instance_exec(#{Thread.current.object_id},#{caller.object_id})" Object.class_eval{ define_method(mname, &block) } begin ret = send(mname, *args) ensure Object.class_eval{ undef_method(mname) } end ret end end