Yusuke,

The reason that something like #prepend would be needed is so that  
ruby can provide a good way to do AOP. Your example is not exactly a  
1-1 mapping onto the prepend feature. Instead, you would need to do  
this:

>  module Speak
>    def speak(words)
>      puts words
>    end
>  end
>  module Exclaim
>    def speak(words)
>      super("#{ words }!")
>    end
>  end
>  class Person # Empty class that only includes the module
>    include Speak
>  end
>   class Exclaimer < Person
>    include Exclaim
>  end


If your classes are NOT empty and only include modules, then it is  
impossible to include a module "under" methods defined directly on the  
class. This causes pain when you are using a ruby library that does  
not assume that you will be extending classes. Rails "solved" this  
problem using alias_method_chain, but this method can cause confusion.

I hope I explained my thoughts clearly.

Regards,
Carl Lerche

On Aug 31, 2009, at 5:39 AM, Yusuke ENDOH wrote:

> Hi,
>
> 2009/8/31 Yehuda Katz <wycats / gmail.com>:
>> Matz,
>> As we discussed at LoneStar, I have the following proposal:
> (snip)
>> Effectively, prepend would prepend a module to the class' ancestor  
>> chain.
>
>
> I cannot guess the problem you want to solve.  I know this mail
> is just discussion log or reminder, but I'd like you to elaborate
> your proposal completely when sending to ruby-core.
>
> Why don't you define subclass explicitly?
>
>  class Person
>    def speak(words)
>      puts words
>    end
>  end
>  module Exclaim
>    def speak(words)
>      super("#{ words }!")
>    end
>  end
>  class Exclaimer < Person
>    include Exclaim
>  end
>  Exclaimer.new.speak("matz") #=> matz!
>
> As far as I read your mail, I think this is the correct way.
>
> Do you want to define Person by including Exclaimer?  If so,
> how about this?
>
>  class Person
>    def speak(words)
>      puts adjust_words(words)
>    end
>  end
>  module Exclaimer
>    def adjust_words(words)
>      "#{ words }!"
>    end
>  end
>  class Person
>    include Exclaimer
>  end
>  Person.new.speak("matz") #=> matz!
>
> -- 
> Yusuke ENDOH <mame / tsg.ne.jp>
>