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.

HTH

-----Original Message-----
From: Robert Peirce [mailto:bob / peirce-family.com] 
Sent: Friday, 5 March 2004 11:50 AM
To: ruby-talk ML
Subject: More alias problems


I am missing something important about aliases.  I mentioned the "alias 
:cmd :`" problem before.  I also have a problem with this:

$ cat tst2
#!/usr/bin/env ruby

class Fixnum
         alias plus +
end

puts "#{2 + 5}"			--> 7

puts "#{2.plus(5)}"		--> 7

puts "#{2.plus 5}"		--> 7

# puts "#{2 plus 5}"		--> ERROR

Clearly, plus is not an exact alias for '+' , just as :cmd is not the 
same as :`.  Is it that ruby aliases are not the same as shell aliases?


Bob Peirce                                 Venetia, PA                  
               724-941-6883
bob / peirce-family.com [HOME (Mac)]
rbp / cooksonpeirce.com [OFFICE]

There is? only one basic human? right, the? right to do as you damn well
please.? And with it comes the only basic human duty, the duty to take
the consequences.? -- P.J. O'Rourke