On Wed, 30 Apr 2008 14:32:22 +0900, _why <why / ruby-lang.org> wrote: > On Mon, Apr 28, 2008 at 10:06:05AM +0900, Tadashi Saito wrote: >> I think eval(string) is <del>evil or</del> too ugly and takes more time >> especially in 1.9. It should take block instead of it. > > The sandbox takes the "i" out of eval. A block would be nice, too, > except that I haven't figured out how to change the block's scope so > that it can't reference anything unsafe from its original habitat. I think it would be necessary to extract the block's parse tree and use that to construct a new block within the context of the sandbox. That would of course require that implementors keep the block parse tree around... The main downside with a string eval in this case is that the string must be parsed each time. Accordingly, avoiding that parsing overhead would be the main benefit of using a block. Beyond that, I'm not sure I see much advantage. Proxied method calls on wrapped objects are realistically going to be the main communication method with sandboxes, so that case needs to be optimized more than eval does. -mental