From: Joshua Ballanco Date: 2010-04-07T11:53:14+09:00 Subject: [ruby-core:29288] Re: Proposal: Module#thunk_method On Apr 6, 2010, at 4:17 PM, Charles Oliver Nutter wrote: > Because often the pattern is to do the calculation and then define a > method, like on class load: > > class Foo > a = expensive() > define_method :value do; a; end > end > > in general the pattern is that you want to define a method that > returns a value you have calculated outside the eventual method body. I've just never seen this pattern in the wild. Perhaps you have an example? For the moment, I'll give you the benefit of the doubt that this pattern is used. My question, then, would be why is there a need for a new method? Why not just allow define_method to take an optional value argument in place of the block, and take the fast-path in this case? Honestly, it seems like this is something that could potentially be optimized away by the implementation without the need for an additional core method. - Josh