Project

General

Profile

Feature #249

wish list item: binding.set_local_variable

Added by rogerdpack (Roger Pack) almost 11 years ago. Updated about 8 years ago.

Status:
Rejected
Priority:
Normal
Target version:
-
[ruby-core:17690]

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

History

#1

Updated by Anonymous almost 11 years ago

=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

#2

Updated by rogerdpack (Roger Pack) almost 11 years ago

=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

#3

Updated by rogerdpack (Roger Pack) over 10 years ago

=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

#4

Updated by rogerdpack (Roger Pack) over 10 years ago

=begin
that's with using facets [require 'facets'] before hand
=end

#5

Updated by shyouhei (Shyouhei Urabe) over 10 years ago

  • Assignee set to ko1 (Koichi Sasada)

=begin

=end

#6

Updated by rogerdpack (Roger Pack) over 9 years ago

=begin
This was as expected (not a bug) so can close.
Thanks!
=end

#7

Updated by rogerdpack (Roger Pack) over 9 years ago

  • Status changed from Open to Rejected

=begin
Turns out this is indeed possible.
=end

Also available in: Atom PDF