Robert Peirce wrote:
> 
> On Mar 4, 2004, at 8:03 PM, Mehr, Assaph (Assaph) wrote:
> 
>> Ruby aliases are just making an object respond to a different name 
>> with an existing method; not expanded like shell aliases.
>>
>> If I understand correctly when the parser sees: 2 + 5
>> It actually performs: 2.+ 5
>> i.e. send the '+' method to the FixNum object for 2, with a parameter 
>> of 5.
> 
> 
> Okay, but why doesn't it do the same when it sees 2 plus 5?  2.plus(5) 
> and 2.plus 5 both work but 2 plus 5 does not.
> I'm not saying it should; I'm just wondering why it doesn't.  I don't 
> really understand what is going on when you use
> aliases.

Aliases aren't macros, and the parser doesn't have the artificial
intelligence to rewrite itself every time you use one.

An ordinary method name can only be called with the .meth notation.
That's a syntax issue.

As a bonus, Ruby allows intuitive shorthand making certain methods
look like the operators they represent/are. So that instead of
saying 3.+(5), we're allowed to say 3 + 5. That's also a syntax
issue.

The mere fact that an alias refers to a method that happens to have
an infix shorthand doesn't mean that the Ruby parser is now magically
able to recognize infix method names.

Does this help any?

Hal