[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Dynamic alias

Trans

8/6/2007 5:55:00 PM

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.


2 Answers

Trans

8/6/2007 6:15:00 PM

0



On Aug 6, 10:54 am, Trans <transf...@gmail.com> wrote:
> Honestly, alias bugs me to know end.

Oops! Maybe I meant "To no known end" ;)

T.


Robert Klemme

8/6/2007 6:24:00 PM

0

On 06.08.2007 20:14, Trans wrote:
>
> On Aug 6, 10:54 am, Trans <transf...@gmail.com> wrote:
>> Honestly, alias bugs me to know end.
>
> Oops! Maybe I meant "To no known end" ;)

Oh, and I thought you meant "to no end". :-)

robert