From: Nikolai Weibull Date: 2010-04-07T18:23:29+09:00 Subject: [ruby-core:29297] Re: Proposal: Module#thunk_method On Wed, Apr 7, 2010 at 06:11, Charles Oliver Nutter wrote: > It might be possible to inspect the contents of the define_method > block, see that it's always returning a given value, and optimize the > rest away. You may have to also inspect the surrounding scope to see > that it has not escaped and that any variables referenced will never > be updated again. There are probably ways to do it, but they're all > rather sticky. memo_method would be a handful of lines of code in any > implementation and could be finished and working very quickly. I rather think having the intepreter/compiler optimize for this case makes a whole lot more sense than adding another method to Module. That said, I think constant_method is a better name than memo_method (though GCC���s const function attribute does allow a function to examine its parameters).