From: "Radosław Bułat" Date: 2008-12-18T22:05:59+09:00 Subject: [ruby-core:20642] Re: Proposal: Proc#bind As far as I understand Pawel proporsal he wants to do smth like this: proc = Proc.new { puts self.inspect } a = [1, 2, 3] h = { "foo" => "bar" } s = "foo" p_a = proc.bind(a) p_h = proc.bind(h) p_s = proc.bind(s) p_a.call # => [1, 2, 3] p_h.call # => {"foo" => "bar"} p_s.call # => "foo" I know that in ruby 1.8/1.9 i can do this: class Proc def bind(other) return Proc.new do other.instance_eval(&self) end end end and it will work: proc.bind([]).call proc.bind({}).call But the problem is in implementation because it create some chain. It call's original proc with instance_eval. So after several proc.bind(...).bind(...) we have some unnecessary calls. Is there any problem to add this to Ruby core? Maybe some issue with implementing it? I guess it shouldn't because for example class UnboundedMethod have #bind method and Method have #unbind method. It should works like this (but probably #unbind doesn't make sens because there is no such thing like UnboundedProc). Any comments on this? Matz and the rest? -- Pozdrawiam Rados�aw Bu�at http://radarek.jogger.pl - m�j blog