From: "matz (Yukihiro Matsumoto)" <matz@...>
Date: 2012-11-20T23:07:06+09:00
Subject: [ruby-core:49746] [ruby-trunk - Feature #3688][Rejected] redef keyword for method redefinition in Ruby 2.0


Issue #3688 has been updated by matz (Yukihiro Matsumoto).

Status changed from Assigned to Rejected

To eliminate alias_method_chain, we introduced Module#prepend.
There's no chance to add redundant feature in the language.

Matz.

----------------------------------------
Feature #3688: redef keyword for method redefinition in Ruby 2.0
https://bugs.ruby-lang.org/issues/3688#change-33319

Author: sunaku (Suraj Kurapati)
Status: Rejected
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: Next Major


=begin
 Hello,
 
 I saw Matz's Euroko 2010 keynote[1] where he mentioned adding the
 ability to redefine methods gracefully in Ruby 2.0.  I mean, more
 gracefully than this:
 
   class Hash
     # save the original method
     alias __original_initialize__ initialize
 
     # redefine the method
     def initialize(*args, &block)
       # do something extra ...
 
       # call the original method
       __original_initialize__(*args, &block)
 
       # do something more ...
     end
   end
 
 I suggest adding a "redef" keyword to Ruby 2.0 for this purpose:
 
   class Hash
     # redefine the method
     redef initialize(*args, &block)
       # do something extra ...
 
       # call the original method
       super
 
       # do something more ...
     end
   end
 
 The "redef" keyword should also have a twin "redefine_method" 
 method for use in block-based metaprogramming:
 
   class Hash
     # redefine the method
     redefine_method :initialize do |*args, &block|
       # do something extra ...
 
       # call the original method
       super
 
       # do something more ...
     end
   end
 
 Thanks for your consideration.
 
 [1]: http://euruko2010.heroku.com/Matz-
=end



-- 
http://bugs.ruby-lang.org/