Hi,
In message "[ruby-talk:5077] Crazy idea? infix method calls"
on 00/09/23, hal9000 / hypermetrics.com <hal9000 / hypermetrics.com> writes:
|What if Ruby could have user-definable methods that could be
|called as infix operators?
Hmm.
| 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...
First of all, more than 10 years ago I designed the language named
`Classic', which has the syntax just like this. But infix method was
not really convenient.
Second of all, Ruby 1.6 consider
> x mymethod 5 # the same thing...
as x(mymethod(5)). So I'm afraid infix method invocation raises
ambiguity.
Speaking of syntax enhancement, method as left hand side of
assignment, e.g.
str.substr(2,5) = "abc"
might be interesting.
matz.