From: Robert Klemme Date: 2009-04-15T21:02:22+09:00 Subject: Re: Proc.call with custom bindings 2009/4/14 Adam Strzelecki : > 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. Why would anyone want to do that? The source of the template does not change for each invocation of the template so there is no point in parsing the unchanged template over and over again. Instead, one would reasonably read the template once (or once after each detected change) and create Ruby code which is simply invoked via a method or block call. Which is what Rails seems to be doing (it creates a method) according to the reference Brian posted. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/