Dynamic alias

Honestly, alias bugs me to know end. When meta-programming, alias is
notorious for causing problems. Not only is it a keyword (yuk), but it
is inherently static.

Well, it doesn’t fix everything of course, but here’s a little snip
that came to me today to take some of the static edge off:

class Module
alias _alias_method alias_method

def alias_method(name,target)
  begin
    _alias_method(name,target)
  rescue
    module_eval %{
      def #{name}(*a,&b)
        #{target}(*a,*b)
      end
    }
  end
end

end

Now it’s possible to alias a method that’s hasn’t been defined yet.

T.

On Aug 6, 10:54 am, Trans [email protected] wrote:

Honestly, alias bugs me to know end.

Oops! Maybe I meant “To no known end” :wink:

T.

On 06.08.2007 20:14, Trans wrote:

On Aug 6, 10:54 am, Trans [email protected] wrote:

Honestly, alias bugs me to know end.

Oops! Maybe I meant “To no known end” :wink:

Oh, and I thought you meant “to no end”. :slight_smile:

robert