------ art_24150_23876641.1152887879164 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/14/06, ara.t.howard / noaa.gov <ara.t.howard / noaa.gov> wrote: > > On Fri, 14 Jul 2006, Sean O'Halpin wrote: > > > Hmmm. I'm still getting "singleton method called for a different > > object (TypeError)" for this (ruby 1.8.4 (2005-12-24) [i386-mswin32]). > > [SNIP] > you robert? Me too, what was I executing??? Sorry, btw. this challenge was not arbitrary: the increase in metaprogramming > popularity means people are doing things like > > def class_method > alias '__instance_method__', 'instance_method' # push > > define_method 'instance_method' do > # ... > __instance_method__ 42 > # ... > end > > ensure > alias 'instance_method', '__instance_method__' # pop > end > > but this is neither thread safe (easy to fix) or re-entrant (not easy to > fix). > what i mean is doing > > class_method{ > class_method{ > } > } > > blows up. > > to avoid this i wanted to develop this pattern > > def class_method > __instance_method__ ethod 'instance_method' # push > > define_method 'instance_method' do > # ... > __instance_method__.call 42 > # ... > end > > ensure > define_method 'instance_method', __instance_method__ # pop > end > > but, of course, we are seeing that it doesn't work. > > regards. > > -a > -- > suffering increases your inner strength. also, the wishing for suffering > makes the suffering disappear. > - h.h. the 14th dali lama > > ------ art_24150_23876641.1152887879164--