From: Charles Oliver Nutter Date: 2010-04-06T09:42:30+09:00 Subject: [ruby-core:29270] Proposal: Module#thunk_method Many people use define_method solely so they can define a new method that just returns a value, such as for memoization. Unfortunately define_method is a full block dispatch, and as a result it can be a lot slower than regular method calls. I propose a new method Module#thunk_method which defines a fast-as-possible method that just returns the value you give it: class Foo thunk_method :value, "some value" end Foo.new.value # => "some value" This would eliminate define_method cases like this: # lazy-memozing value method def value a = some_expensive_calculation self.class.class_eval {define_method(:value) {a}} end Thoughts? Should this go into RedMine? - Charlie