On Fri, Aug 14, 2009 at 10:46 PM, Joel
VanderWerf<vjoel / path.berkeley.edu> wrote:
> Gary Wright wrote:
>>
>> I find it mildly annoying that 'alias' doesn't actually alias the
>> method (i.e. multiple names for the same thing). Instead, alias
>> just replicates an existing method body and associates a new
>> name with the replica. Seems like 'replicate' would be a better
>> keyword for the current semantics.
>>
>> I also have the inability to ever remember which argument to alias
>> is the new name and which argument is the old name.
>>
>> Did 'alias' work differently in the early days of Ruby such that
>> the semantics changed but not the keyword?
>
> +1 to all of above, albeit mildly for me too.
>
> In practice I usually end up with
>
> def myalias(*a,&b); orig(*a,&b); end
>
> even if it started out as an "alias". I don't mind not having a language
> construct for this purpose, since the above is so compact and clear.
>
> --
>   vjoel : Joel VanderWerf : path berkeley edu : 510 665407
>
>

It is strange that as a Unix guy I have never been bothered by this.
As an important use case for my aliases (although I prefer the
alias_method method) I am often using this pattern:

   alias_method :__behavior__, :behavior
   remove_method :behavior # for 1.9
   define_method :behavior do ...
        ...
        __behavior__
   ...

thus the current behavior became second nature.

Maybe it would be nice to have a synonym method in Module that does
what you two expected from alias, that is being dynamically redefined
with its target.

Cheers
Robert


-- 
module Kernel
  alias_method :, :lambda
end