> From: ts [mailto:decoux / moulon.inra.fr] > Subject: [ruby-talk:9195] Re: Redefining singleton methods ... > >>>>> "H" == =?iso-8859-1?Q?Horst Duch=EAne?= <iso-8859-1> writes: > > H> I did not find a solution using aliasing. > > alias is a private method, you can write > > class << A > alias :old_m :m > def m > "new_m" + old_m > end > end > > > H> # Why here but not with modules? > > include call #append_features, if you don't like it you can change it :-) > > Guy Decoux On a related note. How would you change the behavior #append_features to match the behaviour of class Class.new - i.e. module A def A.s end end module B include A end B.singleton_methods # now [] - want ['s']? Ruby seems to be missing the equivalent of C's function pointers (with self as an implicit argument) - am I wrong about this? Right now I can't think of a way to accurately match the behavior of something like class A end def A.s id end class B < A end p B.s != A.s # true .. More generally is there a way to take a singleton method from Object a and declare the equivalent singleton method for Object b (besides the obvious answer of repeating the function definition) - any ideas? Christoph