Robert Dober wrote:
> On Wed, Apr 23, 2008 at 10:37 AM, ts <decoux / moulon.inra.fr> wrote:
>> Robert Dober wrote:
>>  > However, if and only if, the block in the define_method does not use
>>  > the closure we could really inline the block as the code of a method
>>  > defined with def.
>>
>>   What do you want to say with "inline" ?
> As others pointed out "inline" surely is not the best name, but I was
> completely ignorant when starting this thread.
> I learnt so much already here I am not stopping now ;)
> Charles how would you denominate this optimization if I may dare
> asking YAFM [ yet another five minutes (c) Robert Dober]
> of your time.

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.

- Charlie