From: Eric Mahurin Date: 2005-06-08T05:09:24+09:00 Subject: Re: making a duck --- gabriele renzi wrote: > Eric Mahurin ha scritto: > > This brings us > > back to the topic I talked about earlier - unbind/rebind > procs. > > It would be nice if we could do the same thing to a Proc > that > > these methods can do internally > > ... would dynamic variables be enough? Christian Neukirchen > has a nifty > implementation of them on his blog. From what I saw, this didn't seem much different than another space for global variables. The main ability I was wanting was to be able to replace local variables with their current value in a proc. I think this would make the ugly *eval(string) methods rarely needed. I just looked through the stdlib and found almost every occurence of *eval(string) and found almost every one looks kind of like this: name = ... var = ... eval("def #{name} .... #{var} .... end") This would work: name = ... var = ... define_method(name.to_sym,proc{.... var ....}.unbind) assuming that Proc#unbind replaced "var" with its current value. A define_class_method method would also be useful. Otherwise there would be no equivalent to the above when doing eval("def self.#{name} .... end"). __________________________________ Discover Yahoo! Find restaurants, movies, travel and more fun for the weekend. Check it out! http://discover.yahoo.com/weekend.html