Feature #249
closed
wish list item: binding.set_local_variable
Added by rogerdpack (Roger Pack) over 16 years ago.
Updated over 13 years ago.
Description
=begin
twould indeed be nice to be able to set local variables in further up scopes.
Not quite sure how this would be accomplished.
Maybe make ruby_scope have a ->prev pointer? And then force the parser to re-run, like it does in eval?
Thanks!
-R
=end
=begin
Hi --
On Wed, 9 Jul 2008, Roger Pack wrote:
Issue #249 has been reported by Roger Pack.
Feature #249: wish list item: binding.set_local_variable
http://redmine.ruby-lang.org/issues/show/249
Author: Roger Pack
Status: Open
Priority: Normal
Assigned to:
Category:
Target version:
twould indeed be nice to be able to set local variables in further up scopes.
Not quite sure how this would be accomplished.
Maybe make ruby_scope have a ->prev pointer? And then force the parser to re-run, like it does in eval?
That would sort of do away with the notions of local scope, though. I
think it's important for there to be true local scope, such that
variable names can be changed and eliminated during refactoring, say,
without being coupled to other code.
David
--
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails July 21-24 Edison, NJ
Advancing With Rails August 18-21 Edison, NJ
See http://www.rubypal.com for details and updates!
=end
=begin
yeah this appears to be low priority. I'm able to overcome it with 1.8.x with MRI + parsetree about the same way this would have given me.
=end
=begin
Appears that it's already possible:
a = 3
=> 3
b = binding
=> #Binding:0x4e66c6c
b.eval("local_variables")
=> ["_", "rockies", "all", "o", "g", "a", "b"]
b.eval("a = 4")
a
=> 4
for better or worse.
Fascinating.
-=R
=end
=begin
that's with using facets [require 'facets'] before hand
=end
- Assignee set to ko1 (Koichi Sasada)
=begin
This was as expected (not a bug) so can close.
Thanks!
=end
- Status changed from Open to Rejected
=begin
Turns out this is indeed possible.
=end
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0