From: Tony Arcieri Date: 2010-01-26T05:56:44+09:00 Subject: Why is the Binding object so useless? --000e0cd56d20e28345047e0366f7 Content-Type: text/plain; charset=ISO-8859-1 I am used to Ruby being a rather reflective language that gives carte blanche to the programmer. So I found this rather surprising: >> Marshal.dump binding TypeError: no marshal_dump is defined for class Binding Whaa? >> Binding.new NoMethodError: undefined method `new' for Binding:Class Huh? >> binding.methods(false) => [] You're kidding me, right? I would expect you to be able to do all of the above. In addition to that, it's sure be nice to do some of the following: >> Binding.new :a => 1, :b => 2, :c =>3 => # # new binding object with the given variables bound >> binding.to_hash => {:a => 1, :b => 2, :c => 3} # Bound variables, as a hash >> binding.to_yaml => "--- !ruby/object:Binding \na: 1\nb: 2\nc: 3\n" # YAML dump of a Binding object And hey, maybe Binding#inspect could give a little more information than its object_id? Canned responses to apologists: = Why do you want to do that? I don't know, why should you be able to redefine Integer#+? = No really, why do you want to do that? I would like to implement a remote REPL with a stateless Ruby server and a non-Ruby client = Just use DRb! I am really not wanting to open up an addition port just for DRb nor pursue solutions which involve a non-Ruby client talking the DRb protocol. Embedding some form of Ruby interpreter client side is not an option. Props to Rubinius for fixing some of these problems! irb(main):001:0> Binding.new => # Yay! A clean binding! >> Marshal.dump Binding.new => "\004\bo:\fBinding\000" Amazing! -- Tony Arcieri Medioh! A Kudelski Brand --000e0cd56d20e28345047e0366f7--