Forum: Ruby-core Different eval/binding behaviour in 1.9

45196398e9685000d195ec626d477f0e?d=identicon&s=25 Thomas Sawyer (7rans)
on 2013-01-12 20:25
(Received via mailing list)
Issue #1926 has been updated by trans (Thomas Sawyer).


I guess you don't.
----------------------------------------
Bug #1926: Different eval/binding behaviour in 1.9
https://bugs.ruby-lang.org/issues/1926#change-35378

Author: candlerb (Brian Candler)
Status: Rejected
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category:
Target version: 1.9.2
ruby -v: ruby 1.9.2dev (2009-07-18 trunk 24186) [i686-linux]


=begin
 In 1.8.6, you can set a local variable in a binding using eval. This
doesn't seem to work in 1.9.2-preview1.

   def define_a(b)
     eval "a=1", b
   end

   define_a(binding)
   puts local_variables.inspect
   # 1.8: prints ["a"]
   # 1.9: prints []

 Similarly:

   def another_a(&blk)
     eval "a=1", blk.binding
     yield
   end

   another_a do
     puts local_variables.inspect
   end
   # 1.8: prints ["a"]
   # 1.9: prints []
=end
This topic is locked and can not be replied to.