From: Zsban Ambrus Date: 2004-05-03T19:06:10+09:00 Subject: Re: Why no Proc##[]=() ? Why no Proc##replace() ? On Mon, May 03, 2004 at 01:45:45PM +0900, Jean-Hugues ROBERT wrote: > > Hum... OK. I am wrong. How can I have a block variable that survives > multiple across multiple invocation ? > > I had tried with a local variable, but that did not work. So I tried > with an instance variable, and it seemed to work (but does not, > because I was wrong assuming self was the Proc object, whereas in fact > it is the enclosing method's self, which makes sense BTW). > > BTW: Where can I save the result of long_method, if neither in a > class variable, nor in a local variable ? You don't. A proc is just a simple lambda without mutable internal state. If you want a proc-like object that can have mutable internal state, define a class and define its [] method. That's simpler. Ok, it is possible with lambdas too, but I'm not sure how exactly. > > Is there such a thing that "current_block()" or whatever method > that tells me what the Proc object is ? > > I guess my example with self.replace { mutated_block } was wrong too > (it was not supposed to work anyways because replace is not there > for Proc/s). So... How can a block remember things ? > > Yours, > > Jean-Hugues >