On Wed, 14 Jan 2009 10:51:35 +0900, Charles Oliver Nutter wrote: > Yukihiro Matsumoto wrote: >> One possible idea is making "binding" read-only, or noting that eval >> with binding may not modify the original binding. > > That would be a reasonable compromise. So binding would make a copy of > the captured scope, rather than reference it. It seems like there are > few use cases for being able to capture a binding and mutate captured > values. > > - Charlie You can't use read-only bindings, because then a trick like the following fails: #start by cluttering up the current scope with all kinds of local #variables, all to load code into the variable literate_program def empty_scope self.class.class_eval {remove_method :empty_scope} binding end eval literate_program, empty_scope I don't like the idea of even the copying restriction. While you may think that local variables are sacred, I think that sacredness should be overrideable just like everything else, and when a binding is explicitly passed, it should have access to change things in the binding. Maybe the solution in your world is that Proc#binding needs to be changed somehow to provide more of a guarantee. I'm not convinced that local variables are so sacred that a few useful conveniences aren't in order. We expect people to use all kinds of other power responsibly (including the power to overwrite all of the operators on core classes), so why couldn't we have Proc as binding or Binding.of_caller as a convenience that rivals the simplicity of C macros. I certainly don't want to see Proc#binding go away completely. Consider particularly the s-expression generator in my SqlStatement gem. For it to operate as expected (using RubyNode in Ruby 1.8), I need to have access to the caller's local variables so that I can explicitly substitute in the local variable's value when the appropriate reference to the local variable is found. I'm doing this with the Binding from a Proc. If you eliminate that feature, and I have to pass in an explicit binding, then you've doubled the work involved in using an otherwise really nice and clean convenience. --Ken -- Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/