From: Nobuyoshi Nakada Date: 2011-01-13T08:57:41+09:00 Subject: [ruby-core:34451] Re: [Ruby 1.9-Feature#4254][Open] Allow method transplanting Hi, At Thu, 13 Jan 2011 01:48:33 +0900, Jonas Pfenniger (zimbatm) wrote in [ruby-core:34444]: > I agree with matz. If it's something we want for the next releases, > then it should not break anything. Having transplantable Module > methods already unlocks lots of scenarios, where a module can act as a > bag of methods. For example it allows using methods with > define_method, which allows having regular argument-passing, in > contract with blocks, which capture the current context and don't > allow a block as argument. This in turn allows > to find new patterns that can replace alias_method_chain. If we have that, > then it's already wonderful. 1.9 already allows a block having block-passing. class A def foo yield "A" end end class B < A a_foo = instance_method(:foo) define_method(:foo) do |&block| a_foo.bind(self).call {|s| block.call(s+"B")} end end B.new.foo {|x|p x} #=> "AB" -- Nobu Nakada