Paul Brannan wrote: > On Thu, Apr 24, 2008 at 02:56:54AM +0900, Charles Oliver Nutter wrote: >> Hmm, block unwrapping? Essentially what you want to do to make >> define_method methods as fast as regular methods is to make them regular >> methods; that means unwrapping the block and making its body the body of >> an actual method, rather than doing block dispatch semantics wrapped in >> method dispatch semantics. And with 1.9's much more restrictive block >> arguments, you're not losing much there. Obviously you lose the fact >> that it might be a true closure, and you'd have to go through the >> AST/bytecode and check for variable depths > 0, but it would be worth it >> to make performance decent. IMHO define_method would be a lot more >> useful if it actually made a (fast) method rather than an ugly (slow) >> conglomeration of a method and a proc. > > But if you don't need to access variables outside your scope, then why > use define_method at all? In that case def works just fine. define_method :foo, &some_proc - Charlie