From: Adam Strzelecki Date: 2009-04-15T00:11:31+09:00 Subject: Proc.call with custom bindings If it possible to call Proc instance with custom bindings. I am aware that Proc gets its bindings at the moment it is declared (created). And I can access them with proc.bindings, but is there a way to do Proc#bindings= or to do something similar to Kern.eval(src, bindings) 2nd param? The reason I am asking, is that I am thinking about improving performance of template engines that generate Ruby code upon parsing template, and then call eval(@precompiledsrc) upon each render of template. I believe it would be faster if instead of generating just Ruby code template engines such as ERB or Haml were doing at precomilation stage also: @proc = eval("Proc.new { #{@precompiledsrc} }") and upon each request (render) calling: @proc.bindings = call_locals @proc.call Instead of just calling eval(@precompiled, call_locals) upon each render (request). We could spare CPU cycles that are parsing all over again same Ruby code. BTW. I know there's instance_eval, but it doesn't set local scope variables for Proc. Best regards, -- Adam Strzelecki -- Posted via http://www.ruby-forum.com/.