Feature #249
wish list item: binding.set_local_variable
| Status: | Rejected | Start date: | 07/09/2008 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | - | |||
| Target version: | - |
Description
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
History
Updated by Anonymous almost 4 years ago
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!
Updated by rogerdpack (Roger Pack) almost 4 years ago
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.
Updated by rogerdpack (Roger Pack) over 3 years ago
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
Updated by rogerdpack (Roger Pack) over 3 years ago
that's with using facets [require 'facets'] before hand
Updated by shyouhei (Shyouhei Urabe) over 3 years ago
- Assignee set to ko1 (Koichi Sasada)
Updated by rogerdpack (Roger Pack) over 2 years ago
This was as expected (not a bug) so can close. Thanks!
Updated by rogerdpack (Roger Pack) over 2 years ago
- Status changed from Open to Rejected
Turns out this is indeed possible.