gwtmp01 / mac.com wrote: > The mnemonics are all wrong if you flip it: > > obj <- message # sending the message to the object > obj -> message # sending the object to the message? > > You have to think of <- as a two character operator. Of course > the parser would also have to think of it that way. There would have to > be some white space to have it parse as '<' and '-' separately. My only > point is that it can be parsed, but a syntax that was a bit more > stable with respect to white space would certainly be better. I realize it's not as intuitive at first glance, but i don't think it's "all wrong". in fact, "->" is what Perl and PHP both use rather then a '.' so there is already plenty of precedence for it. the mnemonic disconnect you suggest really comes from calling the obj a "receiver". if it'll help we can avoid that term and find a better way to "read" this. > > As for the class search idea, that can be done easily enough with: > > > > recv.as(BasicObject) -> :class > > This introduces the same problem I pointed out with respect to the > semantics of #send but this time with #as. Ah, good point. Damn, and I really liked the #as method too. > In fact it is worse because > you've got normal method call syntax but completely different semantics > since > recv.as(BasicObject) > will parse as an expression to be evaluated as the lhs of the '->' > operator. > What kind of object would #as return and how would the -> operator know > about the receiver? Well, that's not really an issue i don't think. It just returns a suitable proxy. But your first point makes it rather mute in any case. > > To outline, this would give ruby a complete set of dispatch operators: > > > > . literal > > <- dynamic > > <<- functional (dynamic) > > <~ pervasive (dynamic) > > Having a syntax for starting method lookup in a particular class also > gives you a way to call a method that has been redefined without having > to play games with aliases: > > class A; def m; end; end > class B < A; def m; end; end > > class C > def example > self.m # calls B#m > (self, A) <- :m # calls A#m (kind of ugly syntax though) > end > end Agree with that, which is what I've used #as for too. Can the (self, A) syntax you suggest really work w/o problem? I fear it might go against Matz's no look-ahead rule for the parser. Is that true? And if it is, have you any other suggestion for it? T.