From: hal9000@... Date: 2000-09-23T07:10:03+09:00 Subject: [ruby-talk:5077] Crazy idea? infix method calls This is a generalization of the "in" operator idea which I just posted. It is a very tentative suggestion. There are probably good reasons it should not be done, and it could possibly create a parsing nightmare that is hard to envision. I am mentioning it anyway, though, because Ruby is well-known for doing things that are impossible or at least unlikely. The idea: In everyday life, we tend to think in terms of operators, which is why Ruby represents many of its methods as infix operators. Some operators are even words rather than symbols -- and, or, etc. What if Ruby could have user-definable methods that could be called as infix operators? In my view, this is more or less equivalent to leaving out the dot in a method call, e.g. X opr Y is the same as X.opr Y (obviously it should be a binary operator -- in other words, a method that takes only one parameter not counting the receiver). I think omitting the dot could be a signal to the parser that the method is going to have only one parameter. This could even be done when there were default values for all the parameters but the first: def mymethod(alpha, beta=0, gamma=1) ... end x.mymethod(5,0,1) # All of these x.mymethod(5,0) # method calls x.mymethod(5) # would do x mymethod 5 # the same thing... Of course, I would limit the methods to ordinary method names -- trying to define a new infix operator represented as a punctuation mark would introduce more problems than even I would want to think of... Any comments??? Hal -- Hal Fulton Sent via Deja.com http://www.deja.com/ Before you buy.