From: Paul Brannan Date: 2002-06-07T04:54:45+09:00 Subject: Re: Pascal-like 'with' statement? On Fri, Jun 07, 2002 at 04:30:25AM +0900, Rob Partington wrote: > > I think this latter one used to be implemented using instance_eval, > > which can be dangerous. > > Not unless someone changed my code without telling me. :) My apologies; I didn' have the source, so I was going by memory. :) This one uses instance_eval: http://saxa.georgetown.edu/~jack/ruby/rosa/meth.php?c=1 and was also posted on Rubygarden at: http://www.rubygarden.org/article.php?sid=109 Yours uses send(), which can be almost as bad if not used carefully. It's also a lot simpler and easier to understand than a solution that doesn't allow calls to private methods. BTW, I think there's a typo in the online source. Line 18 should be changed from: @curObj[-1].send(methname, args) .to: @curObj[-1].send(methname, *args) Paul