From: SASADA Koichi Date: 2012-07-10T03:56:44+09:00 Subject: [ruby-core:46282] Re: [ruby-trunk - Feature #6710] new special binding specifier :isolated Hi, (2012/07/09 23:19), jballanc (Joshua Ballanco) wrote: > I like this idea, but I have one question: why make this a special argument to `eval` and not to `Binding.new`? Just a performance. My proposal doesn't make any binding object. It is similar that `nil' specifier (means current binding). > I've wanted `Binding` to become better specified and more refined for some time now, and I think this would be a good step in the right direction. I think at some point it would be good to think about all of the things that can happen in a binding (e.g. specify locals, shadow locals, function defs, shadow defs, new classes, reopening classes, etc.), and give an API to tell bindings what they can and cannot do. > > So, in this case, ISOLATED_BINDING would be something like > b = Binding.new(TOPLEVEL_BINDING) # New binding "inherits" from Top Level (but not same as class inheritance) > b.live_locals = false # This binding will not propagate locals to its "parent" binding (TOPLEVEL_BINDING, in this case) > eval('def foo; end; a = 10', b) # method foo is now available, but local "a" is not > > This, obviously, requires a lot more thought and work, but for now we could maybe at least have `Binding.new(isolated: true)` as shorthand for the case described above? This is another feature. Make another ticket for it if you want. I agree that we need more and more thought to introduce your proposal. -- // SASADA Koichi at atdot dot net