Project

General

Profile

Actions

Feature #249

closed

wish list item: binding.set_local_variable

Added by rogerdpack (Roger Pack) over 15 years ago. Updated almost 13 years ago.

Status:
Rejected
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

Actions #1

Updated by Anonymous over 15 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

Actions #2

Updated by rogerdpack (Roger Pack) over 15 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

Actions #3

Updated by rogerdpack (Roger Pack) over 15 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

Actions #4

Updated by rogerdpack (Roger Pack) over 15 years ago

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

Actions #5

Updated by shyouhei (Shyouhei Urabe) about 15 years ago

  • Assignee set to ko1 (Koichi Sasada)

=begin

=end

Actions #6

Updated by rogerdpack (Roger Pack) over 14 years ago

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

Actions #7

Updated by rogerdpack (Roger Pack) over 14 years ago

  • Status changed from Open to Rejected

=begin
Turns out this is indeed possible.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0