Hi,

From: "Nathaniel Talbott" <ntalbott / rolemodelsoft.com>
Subject: [ruby-talk:13084] RE: [ANN] Lapidary 0.2.0
Date: Fri, 23 Mar 2001 01:45:19 +0900

> Jim Menard [mailto:jimm / io.com] wrote:

> One off topic question is, why isn't alias_method() named copy_method? Seems
> clearer about what it actually does.

Because what alias actually does is making an alias :-)

As far as alias is concerned, you can view method definition
just like assigning proc objects to variables.

  foo = proc { Dave() }     # def foo; Dave(); end
  bar = foo                 # alias bar foo
  foo = proc { Fred() }     # def foo; Fred(); end
  bar[]                     # => Dave

I guess what you had in mind was something like bellow.

  foo[0] = { Dave() }
  bar = foo                 # alias bar foo
  foo[0] = { Fred() }
  bar[0][]                  # => Fred
  
You see the alias part works in the same way, but end result is
diffetent.

BTW, one common apprication of alias is inserting extra code
into existing method.    

Something like....

  class String
    alias __to_s__ to_s 

    def to_s
      "``" + __to_s__ + "''"
    end
  end

This will end up infinite recursion if redefining to_s will
change __to_s__ as well.

Regards,
Kenichi Komiya.