From: Robert Feldt Date: 2001-03-06T12:45:44+09:00 Subject: [ruby-talk:12076] Re: ANN: Memoize 0.1.2 On Tue, 6 Mar 2001, Avi Bryant wrote: > So somehow I'm messing up the block_given? call; I'm not sure how. > Ideas, anyone? > Yes, its kind of strange that it is messed up. My interpretation of what your trying to do with advice.c is (in Ruby code with generality taken away): --- def orig puts "hello world" puts block_given? end def real_call(&b) Object.send(:orig) end def call_method real_call {yield} end def call_advice(&b) advice(&b) end def advice puts "pre" yield puts "post" end def dispatch call_advice {call_method} end dispatch --- Is that a correct interp? (BTW, I'm not sure I understand the need for real_call and call_method with the yield. Cant they be merged? Or will it not work when we want to alter what is returned from the advice?) The above code works and does not mess up the block_given? call. I guess the problem might be in a difference between in how rb_iterate handles the iter stack as opposed to when the above Ruby code is executed. But my knowledge of Ruby internals is too limited. Matz or Guy or any other one? /Robert