From: "Martin Dürst" Date: 2011-07-13T10:04:02+09:00 Subject: [ruby-core:38034] [Ruby 1.9 - Feature #5005] Provide convenient access to original methods Issue #5005 has been updated by Martin D��rst. Just some general thoughts on making metaprogramming easier: Using metaprogramming in Ruby is on average somewhat more lengthy/clumsy than straightforward/plain (i.e. non-meta) programming. I have been thinking about why that may be. It could just be that most of the attention has been on plain programming, and metaprogramming hasn't been polished as much yet as plain programming. But over time, I got the impression that to some extent, leaving metaprogramming to be somewhat more clumsy may have been intentional. Metaprogramming is a very powerful tool, and therefore programmers should think hard about how to use it well. If it gets too easy and straightforward, then it's going to be overused. I agree that method patching as in this feature request and in #3688 is very frequent. But it is often a quick patch to an underlying problem that might benefit from further thought. If we make it easier with 'redef' or 'original' or some other keyword or syntax, then it will easily become even more over/abused. This may also apply to other cases of metaprogramming. ---------------------------------------- Feature #5005: Provide convenient access to original methods http://redmine.ruby-lang.org/issues/5005 Author: Lazaridis Ilias Status: Open Priority: Normal Assignee: Category: core Target version: 2.0 The languag allows a class to be "reopened", thus it's behaviour can be redefined: class String def any_method #custom code end end the original method can be called, using this construct: class String alias_method :original_any_method, :any_method def any_method(*args) #custom code original_any_method(*args) #custom code end end In order to make this more convenient, the following construct could be provided: class String def any_method(*args) #custom code original # call the original String#any_method, passing *args (similar to "super") #custom code end end "original" would behave similar to "super" The term "original" can be replaced by any term which describes this concept better. -- http://redmine.ruby-lang.org