From: Albert Schlef Date: 2009-12-31T18:44:58+09:00 Subject: Re: Why can't I use "or" here? Seebs wrote: > On 2009-12-31, Albert Schlef wrote: >> So it seems Ruby internally recognizes some structures as "statemenets" >> and others as "expressions". It seems disapointing at first, but since >> Ruby supports precedence for operators (something Lisp doesn't), there >> has to be some price to pay. > > I don't think that's it at all. I think it's that methodname( is a > method > call (), not a grouping (). Thus the difference between > puts(a or b) > and > puts (a or b) > > In short, it's nothing to do with statements-vs-expressions, and > everything > to do with disambiguating method calls vs. parenthesized expressions. I don't think there's a disagreement between us: Here is a method call in Ruby: method_name ARG , ARG , ARG , .... ARG can be the expression "2", for example. But is can't be the expression "2 or 3". So the compiler has to classify "2 or 3" as something that can't stand for an ARG. So the compiler classifies it as a STATEMENET and decides that a STATEMENT can stand for an ARG. BTW, I can imagine why "2 or 3" couldn't be a method argument. This would only be possible if "or" has higher precedence than ",", or else `func(1, 2 or 3, 4) would wreak havoc. But then `do_this() or a, c = d, e` would fail, because it'd mean `(do_this() or a), c = d, e`. -- Posted via http://www.ruby-forum.com/.